我最近为我的应用转移了提供商,现在当应用尝试发送邮件时出现以下错误
邮箱不可用。服务器响应是:不允许传递到此地址。
我尝试了各种不同的电子邮件地址,以及他们的技术支持,但事实证明这些地址没那么有用。
这是一个asp.net mvc应用程序,控制器代码是:
public ActionResult EmailEventRegister(int eventId)
{
//Find Event
var eventSel = db.Events.FirstOrDefault(t => t.EventId == eventId);
MailMessage enteredMessage = new MailMessage();
enteredMessage.Subject = "YFA Event Attendance Details for " + eventSel.Name + " " + eventSel.EventDate.ToLongDateString();
enteredMessage.IsBodyHtml = true;
var bodyBuilder = new StringBuilder();
bodyBuilder.AppendLine(branch.BranchName + " YFA are attending the following event: " +
"<br />" +
"<br />Event: " + eventSel.Name +
"<br />");
enteredMessage.Body = bodyBuilder.ToString();
enteredMessage.From = new MailAddress("phillsanders@me.com", "Droitwich YFA");
enteredMessage.CC.Add("phillsanders@me.com");
enteredMessage.To.Add(new MailAddress("phillsanders@me.com"));
SmtpClient mySmtpClient = new SmtpClient("icebreak.host4asp.net");
NetworkCredential Credentials = new NetworkCredential("contact@yfainfo.com", "Passwordhere");
mySmtpClient.Credentials = Credentials;
mySmtpClient.Send(enteredMessage);
mySmtpClient.Send(enteredMessage);
var userId = User.Identity.GetUserId();
var branchId = db.Instructors.FirstOrDefault(x => x.ApplicationUserId == userId).BranchId;
return RedirectToAction("Index", "Events", new { branchId = branchId});
}