If you are using ASP to send email on our emailserver, please avoid using CDONTS. We no longer support CDONTS.
Below is the sample source code to send email using Authentication
1 Below is the code snippet for ASP.
2
3 Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
4 Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
5
6 Const cdoAnonymous = 0 'Do not authenticate
7 Const cdoBasic = 1 'basic (clear-text) authentication
8 Const cdoNTLM = 2 'NTLM
9
10 Set objMessage = Server.CreateObject("CDO.Message")
11 objMessage.Subject = "Example CDO Message"
12 objMessage.Sender = "me@mydomain.com"
13 objMessage.From = "me@mydomain.com"
14 objMessage.To = "recipient@test.com"
15 objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."
16
17 '==This section provides the configuration information for the remote SMTP server.
18
19 objMessage.Configuration.Fields.Item _
20 ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
21
22 'Name or IP of Remote SMTP Server
23 objMessage.Configuration.Fields.Item _
24 ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.yourdomain.com"
25
26 'Type of authentication, NONE, Basic (Base64 encoded), NTLM
27 objMessage.Configuration.Fields.Item _
28 ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
29
30 'Your UserID on the SMTP server
31 objMessage.Configuration.Fields.Item _
32 ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username@domain.com"
33
34 'Your password on the SMTP server
35 objMessage.Configuration.Fields.Item _
36 ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"
37
38 'Server port (typically 25)
39 objMessage.Configuration.Fields.Item _
40 ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
41
42 'Use SSL for the connection (False or True)
43 objMessage.Configuration.Fields.Item _
44 ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
45
46 'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
47 objMessage.Configuration.Fields.Item _
48 ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
49
50 objMessage.Configuration.Fields.Update
51 objMessage.Send
52
53 FONT>
Note :
Change the SMTP Server with your mail.yourdomain.com
Username --> Change with your email account in this format (email@domain.com).
Password-> Your email password.