As server technology advances, web developers gain access to better tools. This progress also means that as some components age, they become obsolete and are no longer supported. An example of this on Windows servers is CDONTS. Web developers primarily use CDONTS as a thin client for mailing web forms.
Microsoft already discontinued CDONTS on Windows 2000, Windows XP and Windows 2003 servers. Microsoft also recommends that any scripts using CDONTS be updated using the newer CDOSYS technology or JMAIL.
CDOSYS is the successor of CDONTS, an easy way to send emails from webpages. To test CDOSYS functionality, use the following code saved into a file with an .asp extension. CDOSYS is a built-in component in ASP, so using it from your ASP code takes no additional effort on your part:
<% Set objCDOSYSMail = Server.CreateObject("CDO.Message") Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration") objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1" objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 objCDOSYSCon.Fields.Update Set objCDOSYSMail.Configuration = objCDOSYSCon objCDOSYSMail.From = "firstname.lastname@example.org" objCDOSYSMail.To = "email@example.com" objCDOSYSMail.Subject = "This is my subject for my test message" objCDOSYSMail.HTMLBody = "This is the body " objCDOSYSMail.Send Set objCDOSYSMail = Nothing Set objCDOSYSCon = Nothing %>
Your SMTP server information should always be “127.0.0.1″ or “localhost”. Default SMTP port is 25. If you are having issues sending out using port 25, port 587 can be used as an alternative.
As an alternative to CDOSYS, you may use JMAIL. Below you can find the code that you need to save with a .asp extension:
<% Text="Test" 'send email Set JMail = Server.CreateObject("JMail.SMTPMail") JMail.ServerAddress = "127.0.0.1" JMail.Sender = "firstname.lastname@example.org" JMail.Subject = "Contact Email" JMail.AddRecipient "email@example.com" JMail.ContentType = "text/html" JMail.Body = Text JMail.Priority = 1 JMail.Execute Response.Write Text %>
Just as always SMTP server is “127.0.01″ or “localhost”. Default SMTP port is 25, but port 587 can be used as well.
Note: Please remember that if CDONTS scripts are not updated to either CDOSYS or JMAIL your pages may not work correctly or appear down.