Search code examples
asp.netgmailsystem.net.mail

Error: Server does not support secure connections


Ok, I have been using the following script for over a year now to send email (via gmail) from my host, and it has worked just fine (the Settings.Get() just return strings):

public class Email : SmtpClient
{
    public MailMessage Message { get; private set; }

    public Email(string to, string from, string subject, string body) : base(Settings.Get("smtp"), 25)
    {
        this.EnableSsl = Convert.ToBoolean(Settings.Get("ssl"));
        if(this.EnableSsl)
            this.Credentials = new System.Net.NetworkCredential(Settings.Get("gm"), Settings.Get("gmp"));
        this.Message = new MailMessage(from, to, subject, body);
    }

    public void Send()
    {
        try { this.Send(Message); }
        catch (Exception ex) { throw ex; }
    }
}

But, since yesterday, I have been getting this error:

Error: Server does not support secure connections.

Now of course my host thinks it's not their fault, BUT I DIDN'T CHANGE ANYTHING. Also, it still works fine on my local and test machines. Any idea what might be causing this so I can tell them to fix it?

Thank you... this is driving me nuts!


Solution

  • What SMTP-Server and port are you using? You will need to use port 465 or 587 if you are connecting directly to smtp.gmail.com to send ssl mail.

    It looks like you are using port 25, are you sure that your Settings.Get("ssl") returns false?

    Read here for details.