I need to check if mail was sent to an existing recipient
Here is my code
try
{
var smtpServer = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new System.Net.NetworkCredential(MAIL_FROM, PASSWORD),
EnableSsl = true
};
var mail = new MailMessage();
mail.From = MAIL_FROM
mail.To.Add(new MailAddress("nonexisting@gmail.com"));
mail.Subject = title;
mail.Body = content;
smtpServer.Send(mailMessage);
}
catch (SmtpFailedRecipientsException ex)
{
}
But SmtpFailedRecipientsException never occurs when there is no recipient
Is there a way to configure SmtpServer to trigger this exception?
source
share