Amazon Simple Email Service is not working on port 465 - amazon-simple-email-service

I'm trying to make sending email work using Amazon Simple Email Service SMTP.
I configured the email sending to use port 465 with SSL as the CDOSys available for VB Script does not support TLS. But even so I get the error error '80040211' on the line where the objCDOSYSMail.Send command is located
I tested the connection to port 465 through TELNET and everything indicates that there is no problem connecting to the port.
Below is my test code, I censored only my smtp login and password.
I'm grateful for any help you can offer me. I also tested with ports 25 and 587
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'SERVIDOR DE SMTP
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "email-smtp.sa-east-1.amazonaws.com"
'PORTA PARA COMUNICAÇÃO COM O SERVIÇO DE SMTP
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
'PORTA DO CDO
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Utilização de SSl
objCDOSYSCon.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
'ATIVAR RECURSO DE SMTP AUTENTICADO
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = true
'USUARIO PARA SMTP AUTENTICADO
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "XXXXXXXXXXXXXXXXXXXXXXX"
'SENHA DO USUARIO PARA SMTP AUTENTICADO
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
'TEMPO DE TIMEOUT (EM SEGUNDOS)
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
objCDOSYSCon.Fields.update
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = "loja#sabarabucu.com"
objCDOSYSMail.To = "ronaldo#onemedia.com.br"
objCDOSYSMail.Subject = "Teste"
objCDOSYSMail.HtmlBody = "Testando"
objCDOSYSMail.Send
Set objCDOSYSMail = nothing
Set objCDOSYSCon = nothing

Related

My Classic ASP script contains both lines that require 32bit enabled and disabled application pools

I collect mail addresses from database and send mails using old Classic ASP. JMail requires 32Bit mode disabled in application pool.
Set sender = Server.CreateOBject("JMail.Message")
Recently I've added Oracle DB to collect more mail addresses and noticed the code below requires an application pool with 32Bit mode enabled:
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.35.200)(PORT=1521)))(CONNECT_DATA=(SID=MYDB)(SERVER=DEDICATED)));User Id=MYNAME;Password=MyPass;"
It looks like a weird dilemma. What would be the workaround/solution in my case?
I would change to an ASP Email component that does not have the conflicting requirement. Personally, I've used ASPEmail. It's a google away :).
I've learned very well & used CDO years later. Here is my code:
<%
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
dim objEmail
Set objEmail = CreateObject("CDO.Message")
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")= cdoSendUsingPort
'Name or IP of remote SMTP server
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.domain.com"
'Server port
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpAuthenticate") = cdoBasic
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "info#domain.com"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "thepassword"
objEmail.BodyPart.Charset = "Windows-1254"
'objEmail.TextBodyPart.Charset = "utf-8"
'objEmail.HTMLBodyPart.Charset = "utf-8"
'objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/SaveSentItems") = TRUE
objEmail.Configuration.Fields.Update
objEmail.From = "My Name <myname#domain.com>"
objEmail.To = "The Name <name#targetmail.com>"
objEmail.Subject = "CDO Test"
objEmail.Textbody = "This is a message."
objEmail.HTMLBody = "<h1>This is a message.</h1>"
objEmail.Send
Response.Write "OK"
%>

Send mail with CDO through Google Apps gives transport error: CDO.Message.1 error '80040213'

I'm trying to send an contact enquiry email from a legacy classic asp script using a Google Apps account as the SMTP server. The code I have to test this is as follows:
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
'This section provides the configuration information for the remote SMTP server.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.thedomain.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 ' or 587
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
' Google apps mail servers require outgoing authentication. Use a valid email address and password registered with Google Apps.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="info#thedomain.com" 'your Google apps mailbox address
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="password" 'Google apps password for that mailbox
ObjSendMail.Configuration.Fields.Update
ObjSendMail.To = "me#mydomain.net"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "info#thedomain.com"
' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"
ObjSendMail.Send
Set ObjSendMail = Nothing
I've tried both port numbers 465 and 587. I've tried mail.thedomain.com and smtp.thedomain.com and mail.gmail.com and smtp.gmail.com as the SMTP server, but nothing works. I've logged into the Google Apps account with the email address and password in the script, so those details are definitely correct.
All I can get though is the following error:
CDO.Message.1 error '80040213'
The transport failed to connect to the server.
/_test-email.asp, line 46
(line 46 is where it says ObjSendMail.Send)
Can anyone see what might be wrong?
Thanks folks!
I tried with Gmail smtp server and a little changes to your code and it worked like a charm.
Just modify these 3 parameters and you are good to go.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.gmail.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
Try setting smtpusessl to 1 (true) (I see you have it set to false)

Using classic ASP, is it possible to set the SMTP envelope from address with CDO?

I am sending mail using classic ASP with the CDOSYS objects, but I would like the envelope from address - that is, the one that is specified by MAIL FROM during SMTP - to be set differently to the From header address in the message.
The purpose of this is to implement VERP. For example, I would expect the SMTP dialogue to be something like:
220 mail.example.com ESMTP
[...]
MAIL FROM: <info+test=example.com#mydomain.test>
250 2.0.0 OK
RCPT TO: <test#example.com>
250 2.0.0 OK
DATA
354 Start mail input; end with <CRLF>.<CRLF>
From: Company1 <info#mydomain.test>
To: test#example.com
[...]
In the above example, the envelope from is "info+test=example.com#mydomain.test" but the From header is "info#mydomain.test".
Hope this makes sense. Any ideas?
ok I got it figured out and I wiresharked it and I see the commands as you want them...
Sorry about the horrible answer I gave you before. This will do it... it is the "SENDER" that you want for the MAIL FROM: envelope
Const cdoSendUsingPort = 2
StrSmartHost = "localhost"
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
With iConf.Fields
.item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSmartHost
.Update
End With
With iMsg
Set .Configuration = iConf
.To = "test#example.com"
.Sender = "info+test=example.com#mydomain.test"
.From="Company1 <info#mydomain.test>"
.Subject = "This is a test CDOSYS message (Sent via Port 25)..."
.HTMLBody = strHTML
.Send
End With

asp CDO.Message.1 error '80040213' The transport failed to connect to the server. /check.asp, line 25

CDO.Message.1 error '80040213'
The transport failed to connect to the server.
/check.asp, line 25
please help to solve this problem
check this code
<%# Language=VBScript %>
<html>
<head>
</head>
<body>
<%
dim to_field, message
to_field = Request.Form("to_field")
message = Request.Form("message")
'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.example.com"
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
'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = "admin#example.com" ' the address you want the email to be from
objCDOSYSMail.TO = "anuradha#gmail.com" 'the address the mail is to be sent to
objCDOSYSMail.Subject = "Subject goes here"
objCDOSYSMail.HTMLBody = "fffffffffff"
objCDOSYSMail.Send
'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
%>
<p>Mail sent successfully to address <%=to_field%>!</p>
</body>
</html>
You need to add your user name and password before sending. This is because you used a value of 2 in the sendusing's field. This means you're using authentication.
'Your UserID on the SMTP server'
objCDOSYSCon.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "yourusername"
'Your password on the SMTP server'
objCDOSYSCon.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"

SMTP configuration SendUsing configuration value is invalid with ASP-Classic

I'm trying to get an email sent using ASP classic, and am having trouble with SMTP configuration.
The error:
CDO.Message.1 error '80040220' The "SendUsing" configuration value is
invalid.
The Code(for the email itself):
Set objMsg = Server.CreateObject("CDO.Message")
objMsg.From = "name#name.com"
objMsg.To = "themetatron#gmail.com"
objMsg.Subject = "Procurement Ally Update"
objMsg.TextBody = strBody
The Code I tried to configure with (pt 1):
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "smtpserver") = "127.0.0.1"
.update
End With
That didn't work, so I tried:
objMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
objMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMsg.Configuration.Fields.Update
That also didn't work.
(Yes, I didn't show it, but at the end there's a call to objMsg.Send)
As far as I can tell, the local boxes SMTP service is running and ready to do its duty.
Can anyone help?
If you are specifying an smptserver, be sure to set your 'sendusing' field to 2 (or cdoSendUsingPort) as well:
objMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
objMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMsg.Configuration.Fields.Update
As the SMTP service is on the localhost it makes more sense to send to pickup directory using SendUsingPickup (1). This will be more efficient than sending over network to port 25.
objMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
objMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "C:\Inetpub\mailroot\Pickup"
objMsg.Configuration.Fields.Update

Resources