Validate if recipient's email address is valid or accepted by specified SMTP server.
[Syntax] Visual C++: HRESULT TestEmailAddr(long* pVal) Visual Basic: TestEmailAddr() As Long
Return Value
Remarks
Example
[VB6, VBA - Test Email Address]
Private Sub TestEmailAddress()
Dim oSMTP As New EASendMailObjLib.Mail
oSmtp.LicenseCode = "TryIt"
oSmtp.FromAddr = "sender@mydomain.com"
'validate the following email address
oSmtp.AddRecipient "tester", "tester@mydomain.com"
If oSmtp.TestEmailAddr() = 0 Then
MsgBox "valid email address"
Else
MsgBox "it may be an invalid email address"
MsgBox oSmtp.GetLastErrDescription()
End If
End Sub
Test Email Address
Validate Email Address Syntax and Test Email Address in VB6
Validate Email Address Syntax and Test Email Address in VC++
Validate Email Address Syntax and Test Email Address in Delphi
Firstly, Mail object performs a DNS MX record query. If it retrieves the recipient's local SMTP server successfully, Mail object will try to connect to this server. Mail object then performs "RCPT TO" command to test if this SMTP server accepts this email address.
Because it totally depends on your networking connection, if your networking connection to the recipient server is bad or your IP address is blocked by the recipient server, test will be failed, but it doesn't mean this email address is invalid.
Moreover, to prevent email address testing, many email providers accept the recipient address at first no matter if the address is valid or invalid, only after you sent the email data to the server, then the server rejects it if the recipient address is invalid.
Send the email to the recipient without testing. If you don't get Transport Error and Failure Report in 24 hours, that means the recipient is valid. If you get Failure Report, you should consider to remove this recipient from your mail listing.
See Also
Bulk Email Sender Guidelines
Process Bounced Email (Non-Delivery Report) and Email Tracking