开发者

Sending email using ASP.NET I am getting this error

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. u6sm344516ibd.6

I have my code like this?

MailAddress to = new MailAddress("xxxxx@gmail.com");
MailAddress from = new MailAddress("xxx@gmail.com");
M开发者_高级运维ailMessage message = new MailMessage(from, to);
message.Subject = "Error Occred in the application:";
message.Body = ex.Message;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);


the SMTP server required that you use a secure connection

client.EnableSsl = true;


You could check if setting the EnableSsl property for SmtpClient to true and specifying the credentials would help.

client.EnableSsl = true;
client.Credentials = new NetworkCredential("user", "password");


You will need to set the appropriate properties of the SmtpClient instance to enable TSL/SSL, and set credentials. Check out this for more:

http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx


Try configuring your SMTP to use port 25 (with SSL).


For gmail Smtp server, use port 587. Port 465 has problems. Make sure you also pass in your correct gmail address and the password that you use with that address/account. Finally, ensure you have set your gmail account to accept connections from other email apps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜