Troubleshooting: SMTP

Common reason of the messages not being sent is one of the following:

  • Server requires SMTP authentication
  • Authentication failed (wrong UserName and/or Password, unsupported authentication method). You can try several common choices:
    • UserName=Account_name (e.g. "jdoe" if your e-mail address is "jdoe@domain.com")
    • UserName=E-Mail_address (e.g. "jdoe@domain.com")
    • Try different values for AuthMethod property (such as 1, 2, 3, 4, 5)
  • Specified server is not SMTP ( ErrCode=4 in this case). For example, SMTP server name for "jdoe@domain.com" is usually somewhat like "mail.domain.com" or "smtp.domain.com" BUT NOT just "domain.com"
  • SMTP server rejects connections from your IP address
  • SMTP server is behind firewall
  • Specified "From:" address is not allowed by this server
  • Specified "To:" address is allowed only if the user has already passed SMTP authentication
  • Message size limit exceeded, traffic limit per connection exceeded, etc.

You can determine exact reason of the problem from MailBee's log file. To enable logging, set EnableLogging and LogFilePath properties of the SMTP object.

This sample sends simple e-mail using SMTP authentication. SMTP session log is written into "C:\smtp_log.txt" file.

Visual Basic

Dim objSMTP

Set objSMTP = CreateObject("MailBee.SMTP")

' Enable logging SMTP session into a file
objSMTP.EnableLogging = True
objSMTP.LogFilePath = "C:\smtp_log.txt"
objSMTP.ClearLog

objSMTP.LicenseKey = "put your license key here"

' Set SMTP server name
objSMTP.ServerName = "mail.server.com"

' Enable SMTP authentication
objSMTP.AuthMethod = 2

' Set authentication credentials
objSMTP.UserName = "jdoe"
objSMTP.Password = "secret"

' Set message properties
objSMTP.FromAddr = "sender@firstdomain.com"
objSMTP.ToAddr = "recipient@seconddomain.com"
objSMTP.Subject = "Test"
objSMTP.BodyText = "Body of the test message"

' Try to send message
If objSMTP.Send Then
  MsgBox "Sent successfully"
Else
  MsgBox "Error #" & objSMTP.ErrCode & ", " & objSMTP.ErrDesc
End If

ASP

<%
Dim objSMTP

Set objSMTP = Server.CreateObject("MailBee.SMTP")

' Enable logging SMTP session into a file
objSMTP.EnableLogging = True
objSMTP.LogFilePath = "C:\smtp_log.txt"
objSMTP.ClearLog

objSMTP.LicenseKey = "put your license key here"

' Set SMTP server name
objSMTP.ServerName = "mail.server.com"

' Enable SMTP authentication
objSMTP.AuthMethod = 2

' Set authentication credentials
objSMTP.UserName = "jdoe"
objSMTP.Password = "secret"

' Set message properties
objSMTP.FromAddr = "sender@firstdomain.com"
objSMTP.ToAddr = "recipient@seconddomain.com"
objSMTP.Subject = "Test"
objSMTP.BodyText = "Body of the test message"

' Try to send message
If objSMTP.Send Then
  Response.Write "Sent successfully"
Else
  Response.Write "Error #" & objSMTP.ErrCode & ", " & objSMTP.ErrDesc
End If
%>

See Also:

ErrCode Property