【发布时间】:2014-07-13 13:15:02
【问题描述】:
我正在尝试在系统完成付款处理后向自己发送电子邮件通知。我正在使用以下代码:
public Exception SendEmail(string subject, string body)
try
{
var fromAddress = new MailAddress(Setting.Get("smtp_from"), Setting.Get("smtp_from_name"));
var toAddress = new MailAddress(Setting.Get("smtp_to"), Setting.Get("smtp_to"));
var smtp = new SmtpClient
{
Host = Setting.Get("smtp_host"),
Port = Int32.Parse(Setting.Get("smtp_port")),
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential(fromAddress.Address, Setting.Get("smtp_password")),
Timeout = Int32.Parse(Setting.Get("smtp_timeout"))
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
return null; //All went well
}
catch (Exception ex)
{
return ex;
}
}
没有什么特别之处,只是通过 Google 找到的基本代码。此代码与以下消息和主题完美配合:
Subject: [SUCCESS] Donation processed successfully
Message: This is a test.
但是,当消息变成这样时:
Donation received and processed successfully! No further action is required.
Donor: John Doe
Donation amount: 4,00 EUR
Email: fake@user.com
Mandrill API Response: Sent
我的收件箱中没有任何内容。它确实显示在发送电子邮件的帐户的已发送项目中。我已经检查了所有内容,垃圾邮件,thrash,但它就是没有到达。
有没有人遇到过这种情况?有谁知道如何解决这个问题?
【问题讨论】: