CDO SMTP Authentication Mail Script

CDO can be used to send email without SMTP authentication as well as using SMTP authentication. Following is the sample code to send email using CDO SMTP authentication:

WHMCS Complete Billing and Support


<% Set objEmail = CreateObject("CDO.Message") objEmail.From = "youremail@domain.com" objEmail.To = "someone@domain.com" objEmail.Subject = "Test Mail" objEmail.Textbody = "Test Mail" objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP SERVER NAME" objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1" objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youremail@domain.com" objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Email_Account_Password" objEmail.Configuration.Fields.Update objEmail.Send If Not err.number=0 Then Response.write "ERROR: " & err.Description err.Clear end if %>

Make sure that you use appropriate SMTP server, SMTP server port, username and password to send email via authenticatoin.

Kailash Aghera

Posted in Scripts.

Leave a Reply

Your email address will not be published. Required fields are marked *