Limilabs.Client.SMTP needs authorization but System.Net.Mail.SmtpClient doesn't?

0 votes

I'm currently refactoring code that sends email.
The code is running on the same machine as a SMTP server.
The old code looked simply like this:

using (var client = new SmtpClient())
{
    client.Send(mailMessage);
}

This works and sends the mail.
When I started using Limilabs Mail.dll I started getting this error:

503:This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.

There are no SMTP username or password configured anywhere in the Web.config file.

I understand that SmtpClient uses some kind of default credentials, but I don't know what those are or how to read them and use them in Limilabs' Smtp client...

Can anyone help me out?

asked Nov 22, 2018 by TeunVervers (200 points)

1 Answer

0 votes

SmtpClient is probably using port 25 and your server is incorrectly configured to allow that.

Try using:

smtp.Connect("localhost", 25);

I strongly advise talking to your server administrator and obtaining correct credentials from him.

answered Nov 22, 2018 by Limilabs support (224,080 points)
I'm already using localhost and port 25.
I'm still confused why System.Net.Mail.SmtpClient doesn't need the credentials...
Maybe it's using domain credentials?

The only thing I can advise is to use some network sniffer to see what is it doing.
Still stuck on this...
I'm using MailEnable for SMTP, I've made a mailbox on it so I have credentials to use.
When I use smtp.SupportedAuthenticationMethods() I get 1 result, LOGIN. I use smtp.Connect("localhost", 25, false) to connect to it without SSL (since that's not configured) and use smtp.Login(username,password) to use AUTH LOGIN, with the address and password of the mailbox within MailEnable.
But I still get a 503 (server requires authentication) error when trying to send a message and smtp.IsMutuallyAuthenticated returns false.
IsMutuallyAuthenticated is for SSL/TLS connections only. Still if Login didn't throw it means server accepted credentials.

You can turn on logging to see raw client-server communication:
https://www.limilabs.com/blog/logging-in-mail-dll

Are you absolutely sure you are connecting to the right server?
I'm certain I'm connecting to the right server.

You can see that logs "authenticated" after AUTH LOGIN.
To be honest I don't really understand. It looks like the server is acting incorrectly.

You clearly are authenticated.

Can you send a message from the user, you use to log-in, to the same user?
Yes, I can login and send an e-mail from an MailEnable mailbox to the same mailbox without issue.
When I look in the logs of MailEnable itself, when sending a mail that fails to send, it also shows that the user is authenticated but responds with a 503 as soon as RCPT TO is called.
I'm going to dive into the config of MailEnable.
...