Submit email to threading-pool of FastSender object for receipient's email address validating.
[Syntax] Visual C++: HRESULT Test(IMail* pSmtp, long nKey, BSTR tParam, long* pVal) Visual Basic: Test(pSmtp As Object, nKey As Long, tParam As String) As Long
This method submits an email to threading-pool of FastSender object. FastSender object validates the recipient email address instead of sending email. Once the email address is tested by FastSender, OnSent event will occur.
With this method, your application can test if an email address is valid. Warning: it is not 100% correct.
How does it work? Firstly, FastSender object performs a DNS MX record query. If it queries the recipient's local SMTP server successfully, FastSender object will try to connect to this server. FastSender 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.
How does FastSender work?
FastSender has an inner threading pool based on MaxThreads count. Firstly, Send or SendByPickup submits email to FastSender mail queue. Secondly threading pool retrieves email from mail queue and send it out. Finally OnSent event informs that the email was sent successfully or unsuccessfully.
No. of worker threads in the threading pool of FastSender is automatically adjusted based on the actual usage. The maximum no. of worker threads is up to the value of MaxThread property specified.
[VB6, VBA - Test Email Address with Multiple Threads] Option Explicit Private WithEvents m_oFastSender As EASendMailObjLib.FastSender Private m_oSmtp As EASendMailObjLib.Mail Private Sub SendEmail() Dim recipientAddr(3) As String Dim i As Integer If m_oFastSender Is Nothing Or m_oSmtp Is Nothing Then Set m_oFastSender = New EASendMailObjLib.FastSender Set m_oSmtp = New EASendMailObjLib.Mail m_oSmtp.LicenseCode = "TryIt" m_oFastSender.MaxThreads = 10 'set the maximum no. of worker threads End If m_oSmtp.FromAddr = "email@example.com" recipientAddr(0) = "firstname.lastname@example.org" recipientAddr(1) = "email@example.com" recipientAddr(2) = "firstname.lastname@example.org" For i = 0 To 2 m_oSmtp.ClearRecipient m_oSmtp.AddRecipient recipientAddr(i), recipientAddr(i), 0 ' because we only test the recipient email address, so we don't need to set subject, body text Call m_oFastSender.Test(m_oSmtp, i, "any" ) Next End Sub Private Sub m_oFastSender_OnSent(ByVal lRet As Long, _ ByVal ErrDesc As String, _ ByVal nKey As Long, _ ByVal tParam As String, _ ByVal Sender As String, _ ByVal Recipients As String) If lRet = 0 Then MsgBox Recipients & " email address is passed" Else MsgBox Recipients & ": " & ErrDesc End If End Sub
Test Email Address
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.
Bulk Email Sender Guidelines
Process Bounced Email (Non-Delivery Report) and Email Tracking