Error: Server does not support secure connections

老子叫甜甜 提交于 2020-01-01 20:38:10

问题


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!


回答1:


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.




回答2:


check your event log, maybe the handshake beetwen the your pc and the server is not working.or the certificate is not being downloaded or it may contain errors wich may be something weird comming from gmail




回答3:


Specifying the port to use 587 has also solved that problem for me -

Error: Server does not support secure connections.

The company I for work created a windows service that does some stuff and then sends an email from gmail. In the beginning it sent the email just fine with no problems. After installing the service on a Vista machine we noticed it would not send the email. Then the same thing once we installed it on windows 2008 server. We've even start to notice it a small number of XP machines. Once we changed the port to 587 it started to work fine again and send the emails.

Here is some sample code that has worked on all machines we have tried (XP, Vista, Server 2008).

        Dim client As New Net.Mail.SmtpClient("smtp.gmail.com")
        client.Port = 587
        client.EnableSsl = True
        client.UseDefaultCredentials = False
        client.Credentials = loginInfo
        client.Send(mm)



回答4:


SmtpServer.Port = 587;
SmtpServer.UseDefaultCredentials = false;
SmtpServer.Credentials = new System.Net.NetworkCredential("xx@xx.com", "password");
SmtpServer.EnableSsl = true;



回答5:


Change:

 SmtpServer.EnableSsl = true;

To:

SmtpServer.EnableSsl = false;

This will sort the issue.



来源:https://stackoverflow.com/questions/496566/error-server-does-not-support-secure-connections

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!