0

My application send emails to clients, but now user wants to know whether mail exists or not before sending it, or give notification that email bounced back.

How can i test whether the email inputted by User exists or not before sending mail using C# asp.net if not that then can we check if the mail has been bounced.

  1. I saw TELNET command but it was not working.
  2. I came across something ListNanny ( don't really know how to use it)
  3. I also found VRFY and RCPT ( didn't really looked much on that as of now)

please let me know if anyone has done similar kind of work in their project or POC. Meanwhile I am also looking for solutions.

We are using SMTP server for sending emails and our application is in ASP.NET application.

here is the sample of my code:

 var host = ConfigurationManager.AppSettings[Constants.AppSettings.SMTP_HOST]; var emailFromAddress = ConfigurationManager.AppSettings[Constants.AppSettings.EMAIL_FROM_ADDRESS]; var emailFromName = ConfigurationManager.AppSettings[Constants.AppSettings.EMAIL_FROM_NAME]; using (var mail = new MailMessage()) { mail.Body = body; mail.IsBodyHtml = true; if (!String.IsNullOrEmpty(emailTo)) foreach (var email in emailTo.Split(Constants.Default.EMAILID_SEPARATOR)) mail.To.Add(new MailAddress(email)); if (!String.IsNullOrEmpty(emailCC)) foreach (var email in emailCC.Split(Constants.Default.EMAILID_SEPARATOR)) mail.CC.Add(new MailAddress(email)); mail.From = new MailAddress(emailFromAddress, emailFromName); mail.Subject = subject; mail.Priority = MailPriority.High; if (!String.IsNullOrEmpty(attachmentFilePath)) mail.Attachments.Add(new Attachment(attachmentFilePath)); using (var smtp = new SmtpClient()) { smtp.UseDefaultCredentials = true; smtp.Host = host; smtp.Send(mail); } } 

Thanks.

7
  • its too complicate (and not fast)... aspNetEmail , an old library have this functionality... - yes ListNanny the same company of aspNetEmail - ListNanny is the faster solution Commented Jan 21, 2021 at 12:16
  • @Aristos , can you show me an example of Listnanny , i saw some exaple on ther site they are using NAR file , i am not sure how to generate that. can you explain please Commented Jan 22, 2021 at 6:14
  • I also find this answer just now stackoverflow.com/questions/24733120/… Commented Jan 22, 2021 at 7:00
  • @Aristos, okay let me try it. Thanks for your efforts :) Commented Jan 22, 2021 at 7:06
  • @aristos, it's not working, no matter what email id I select it gives me syntax in the level put. Commented Jan 22, 2021 at 20:28

1 Answer 1

1

an example using the library aspNetMX that we talk about on the comments.

aspNetMX.MXValidate mx = new aspNetMX.MXValidate(); // your server infos mx.SMTPHello = "www.site.com"; mx.SMTPFrom = "[email protected]"; aspNetMX.MXValidateLevel level = mx.Validate("[email protected]", aspNetMX.MXValidateLevel.Mailbox); if (level == aspNetMX.MXValidateLevel.Mailbox) { // Valid email address. } else { // NOT valid email address. } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.