As for this…
I have one unknown – sendto address. I'd like to verify that the info is correct and then manually enter To address.
… that is really not a reliable thing in almost any language, as if it were spammers could have a field day with it. I mean, if I can check if email is valid, then I can better target spam to legitimate address only and not waste cycles / resources on the dudes. Now, there is a PHP module on githib that proports to be able to do this...
… but I've never made any attempt to mess with it.
Outside of the above, here are some points to note about such an effort.
When you say SendTo, if it’s internal, that is easy to ask for via normal Exchange and ADDS lookups, external is the issue.
- You have to connect to the server, and issue a VRFY command. Very few servers support this command, but it is intended for exactly this. If the server responds with a 2.0.0 DSN, the user exists.
- You can issue a RCPT, and see if the mail is rejected.
- If the user doesn’t exist, you’ll get a 5.1.1 DSN. However, just because the email is not rejected, does not mean the user exists. Some server will silently discard requests like this to prevent enumeration of their users. Other servers cannot verify the user, and have to accept the message regardless.
Your last option, it to just use telnet as documented to validate relay. See this article for what this would look like.
Note that the author, is an avid PS guy for years.
Again, most public email servers, will simply reject this sort of thing, or show success as a false positive on direct request like this.