我有一个 MVC 3 应用程序,我在新的托管服务提供商上尝试的所有内容最终都会引发此异常:
“/”应用程序中的服务器错误。信箱不可用。服务器响应是:中继需要身份验证
我尝试使用来自
有很多赞成票,但我仍然得到例外。
我的主机有让我创建邮件帐户的典型面板。我不确定是否要创建 NetworkCredentials,我应该使用什么作为用户名和密码?我一直在使用的是电子邮件地址和电子邮件帐户的密码。
这是我的代码:
public static void sendMail(Joiner request) {
SmtpClient smtpClient = new SmtpClient();
NetworkCredential basicCredential =
new NetworkCredential("garbage@stopthedumpcoalition.org", "REDACTED");
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress("garbage@stopthedumpcoalition.org");
smtpClient.Host = "mail.stopthedumpcoalition.org";
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = basicCredential;
message.From = fromAddress;
message.Subject = "Join the Coalition request from - " + request.FirstName + " " + request.LastName;
//Set IsBodyHtml to true means you can send HTML email.
message.IsBodyHtml = true;
message.Body = "Name: " + request.FirstName + " " + request.LastName + "<br>"
+ "EMail: " + request.Email + "<br>"
+ "Wants to Volunteer: " + request.Volunteer.ToString() + "<br>"
+ "Organization: " + request.Organization + "<br>"
+ "Wants to become a Partner: " + request.Partner.ToString() + "<br>"
+ "Comments: " + request.Comments;
message.To.Add("nivram509@gmail.com");
smtpClient.Send(message);
}