Я не понимаю, я восстановил все свои адреса электронной почты, но сообщение не уходит, и ошибка не отображается.
public ActionResult SendNewsletter(string sujet, string message)
{
try
{
if (ModelState.IsValid)
{
var listEmail = db.NewsLetter
.Select(n => n.Email)
.ToList().AsEnumerable();
var emailList = String.Join(" ; ", listEmail);
var to = new MailAddress(emailList);
// "emailList" recover all my address mail.
var from = new MailAddress("nicolas.urbaniak@sfr.fr");
var sujetMail = sujet;
var mess = message;
var password = "***********";
// if I just insert an address hard the mail share well so the smtp is correct.
using (var smtp = new SmtpClient
{
Host = " mail.sfr.fr",
Port = 25,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(from.Address, password)
})
{
using (
// var courrier = new MailMessage("urbaniak.nicolas@sfr.fr", to.Address)
{
From = from,
Subject = sujetMail,
Body = mess
})
{
smtp.Send(courrier);
}
}
return View();
}
}
catch (Exception e)
{
ViewBag.error = "erreur : " + e;
}
}