【发布时间】:2014-05-08 03:12:15
【问题描述】:
我有一个发送邮件的代码。当我在本地主机上发送邮件时,邮件很容易发送,但是当我将代码上传到服务器时。我遇到了这个异常
System.Net.Mail.SmtpException: The SMTP server requires a secure
connection or the client was not authenticated. The server response
was: 5.5.1 Authentication Required. Learn more at at
System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode,
String response) at System.Net.Mail.MailCommand.Send(SmtpConnection
conn, Byte[] command, MailAddress from, Boolean allowUnicode) at
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify, Boolean
allowUnicode, SmtpFailedRecipientException& exception) at
System.Net.Mail.SmtpClient.Send(MailMessage message) at
Admin_test.Page_Load(Object sender, EventArgs e) in
d:\hostingspaces\abd9009\ihmsgr.domainNames.net\wwwroot\info\test.aspx.cs:line
29
我的代码在我的本地机器和其他服务器上完美运行,但是 在您的服务器上不起作用是这样的:
protected void Page_Load(object sender, EventArgs e)
{
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add("username@gmail.com");
mail.From = new MailAddress("username@gmail.com", "Email
head", System.Text.Encoding.UTF8);
mail.Subject = "This mail is send from asp.net application";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = "This is Email Body Text";
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new
System.Net.NetworkCredential("username@gmail.com", "MyPassword");
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
try
{
client.Send(mail);
}
catch (Exception ex)
{
Response.Write(ex);
}
}
我正在使用服务器上的托管空间http://www.arvixe.com/请帮助
【问题讨论】:
-
尽快删除并重新发布,代码中没有您的 GMAIL 用户名和密码!!!
-
用虚拟用户名和密码修改了亲爱的
-
您仍然可以在修订历史记录中看到您的密码,仅供参考。此时更改密码可能最容易。您应该学习如何使用wireshark 和telnet 实际调试smtp 流量,因为您可能还会遇到其他问题。
-
我更改了密码
标签: c# asp.net .net email authentication