0

I am getting an error in smtp connection when I send a request to stmp server.

IList<MXServer> list = new List<MXServer>(); foreach (string line in result.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { if (line.Contains("MX preference =") && line.Contains("mail exchanger =")) { MXServer mxServer = new MXServer(); mxServer.Preference = Int(GetStringBetween(line, "MX preference = ", ",")); mxServer.MailExchanger = GetStringFrom(line, "mail exchanger = "); list.Add(mxServer); } } 
2
  • 4
    The standard way to do this is, send them an email with a time dependent token and get them to validate it via a web request. Think about it, when is the last time you have filled out a form and it said, sorry thats not your real email address, YOU LIED! Commented Feb 14, 2018 at 12:03
  • Your implementation should be more around "Verify email address"? Once user provides one. Commented Feb 14, 2018 at 12:07

1 Answer 1

1

By using SMTP, you can ask the server if it has the user. SMTP is a text based protocol. But there are some important points:

  1. Every server checks for spam, either this or that way. So your IP address must be a CLEAN one. (not to be listed in spam lists)
  2. Even your IP is clean, repeatedly asking for an address may result your ip to be BANNED
  3. Most service providers bans smtp ports. So you may need a static IP address.
  4. Most servers check for reverse DNS record for inbound connections. So you may need a reverse DNS (PTR) record.
  5. You may need an SPF record.
  6. There are 2 ways to ask an SMTP server: a. VRFY command b. RCPT TO
  7. Most servers are not replying VRFY because of security reasons.

So here is an SMTP session example:

C: MAIL FROM:<[email protected]> S: 250 OK C: RCPT TO:<[email protected]> S: 250 OK C: RCPT TO:<[email protected]> S: 250 OK 

Basically if you get 250 ... answer for a RCPT TO command 90% the email address is ok. Then you can abort the connection.

Sign up to request clarification or add additional context in comments.

3 Comments

How do you do that in C#? I search in google but not found yet.
@Souza you can make a tcp connection. The server will reply in clear text. Then parse the answer.
Thank's. I tried telnet to do tcp connection (WINDOWS SO) and gmail accepted at port 25. And It accepted RCPT command.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.