TestEmailAddr Method

Validate if recipient's email address is valid or accepted by specified SMTP server.

Visual C++: HRESULT TestEmailAddr(long* pVal)
Visual Basic: TestEmailAddr() As Long

Return Value

If this method succeeds, the return value is zero; otherwise the return value is non-zero.


With this method, your application can test if an email address is valid. Warning: it is not 100% correct.
How does it work? Firstly, Mail object performs a DNS MX record query. If it queries 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. If you specified a SMTP server, then this method tests if the specified SMTP server accepts this email address.
Before invoking this method, please make sure your computer is connected to the Internet.


[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"
    MsgBox "it may be an invalid email address"
    MsgBox oSmtp.GetLastErrDescription()
  End If
End Sub

Test Email Address

See Also

Bulk Email Sender Guidelines
Process Bounced Email (Non-Delivery Report) and Email Tracking