Sending Email Using CDO with SMTP Authentication (Legacy)
CDO (Collaboration Data Objects) is deprecated and intended only for legacy Classic ASP applications running on Windows Server with IIS. For modern applications, SMTP libraries or API-based mail services are strongly recommended.
Sample legacy code for sending email using CDO with authenticated SMTP.
Const cdoSendUsingPort = 2
Const cdoBasic = 1
Set objMessage = Server.CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "me@your-domain-name.com"
objMessage.To = "recipient@example.com"
objMessage.TextBody = "This is a sample message." & vbCRLF & "Sent using authenticated SMTP."
With objMessage.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your-domain-name.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "me@your-domain-name.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Update
End With
objMessage.Send
Important notes:
- Port 587 with SSL/TLS is recommended for authenticated SMTP.
- Port 465 may be used if your mail server supports implicit SSL.
- Port 25 is often blocked and should only be used for local or trusted relay.
- Your SMTP username must be the full email address.
- Many providers require app-specific passwords instead of mailbox passwords.
- Port 587 with SSL/TLS is recommended for authenticated SMTP.
- Port 465 may be used if your mail server supports implicit SSL.
- Port 25 is often blocked and should only be used for local or trusted relay.
- Your SMTP username must be the full email address.
- Many providers require app-specific passwords instead of mailbox passwords.
Recommended modern alternatives:
- PHPMailer or Symfony Mailer for PHP
- SMTP libraries for .NET applications
- API-based services such as SendGrid, Mailgun, or Amazon SES
- PHPMailer or Symfony Mailer for PHP
- SMTP libraries for .NET applications
- API-based services such as SendGrid, Mailgun, or Amazon SES