SmtpClient を使用して電子メールを送信するたびに、常に電子メールを受信しますか? まったく理由がわかりませんか?助けてくださいありがとう。
私のコントローラーから:
foreach(var reciever in notifications.ToList() ) {
var msg = new MailMessage();
mail.To.Add(to);
mail.From = new MailAddress("notifications@someone.com");
mail.Subject = subject;
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = body; // contains html email
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
//Add the Creddentials- use your own email id and password
client.Credentials = new System.Net.NetworkCredential(MyConfig.SmtpLogin, MyConfig.SmtpPassword);
client.Port = PlayCaddyMailerConfig.SmtpPort; // 587; // Gmail works on this port
client.Host = PlayCaddyMailerConfig.SmtpServer; // "smtp.gmail.com";
client.EnableSsl = true; //Gmail works on Server Secured Layer
try
{
client.Send(mail);
}
catch (Exception ex)
{
Exception ex2 = ex;
string errorMessage = string.Empty;
while (ex2 != null)
{
errorMessage += ex2.ToString();
ex2 = ex2.InnerException;
}
throw ex2;
} // end try
}