+1 vote

A customer wants to use his internal mail server for sending mail from our application. Therefore is was set up an anonymous smtp access. If we try to use it, mail.dll throws an exception "user or password was not provided".
Is there any possibility to send a mail without providing user and password?

Thanks in advance.

by

1 Answer

0 votes
 
Best answer

When sending simply skip UseBestLogin method:

using(Smtp smtp = new Smtp())
{
    smtp.ConnectSSL("smtp.server.com");

    // smtp.UseBestLogin("user", "password");

    smtp.SendMessage(email);                     
    smtp.Close();   
}      

If you get SmtpResponse exception on SendMessage line, it means that the server in fact needs authentication.

Make sure that you are using correct port, by default Mail.dll uses 587 for non-SSL/TLS connections and 465 for implicit SSL/TLS.

Sometimes companies use port 25.

using(Smtp smtp = new Smtp())
{
    smtp.Connect("smtp.server.com", 25);

    smtp.SendMessage(email);                     
    smtp.Close();   
}

It may be required to use StartTLS for explicit SSL/TLS negotiation, although I don't think that someone that uses anonymous STMP access cares about SSL/TLS:

using(Smtp smtp = new Smtp())
{
    smtp.Connect("smtp.server.com", 25);

    smtp.StartTLS();

    smtp.SendMessage(email);                     
    smtp.Close();   
}
by (297k points)
...