I need to check if mail was send to 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)
{
// never occures
}
But SmtpFailedRecipientsException never occures when there is no recipient
Is there a way to configure SmtpServer to fire this exception?