Getting 4D internet commands to work with Amazon SES email

I signed up for an Amazon SES account to send smtp email from a 4D application. I got the Amazon smtp username (a long random string) and password (a longer random string). Amazon requires SES email to be sent from a verified address which I put in SMTP_Sender. I am using STARTTLS per their instructions by sending via: IT_SetPort (2;587) and then allowing the connection to be upgraded to TLS in SMTP_Send (vlSMTP_ID;0). However, I get an Authentication Error every time (Amazon SES has no lockout as far as I can tell because I did use the wrong password a dozen times). That’s the only error I’ve gotten. I’ve checked by directly entering the correct username and password as strings in the SMTP_Auth command. I also tried by using TLS Wrapper which Amazon SES also accepts. Same Auth Failure.

Is there anyone who has experience with Amazon SES who can give me some hints on how to make it work? I’m beginning to suspect there is a problem with 4D SMTP commands.

The whole email code is:

		Case of 
			: (Not(ERRCHECK ("IT_SetPort";IT_SetPort (2;587))))
			: (Not(ERRCHECK ("IT_SetPrefs";SMTP_SetPrefs (1;1;0))))
			: (Not(ERRCHECK ("IT_Charset";SMTP_Charset (1;1))))
			: (Not(ERRCHECK ("SMTP_New";SMTP_New (vlSMTP_ID))))
			: (Not(ERRCHECK ("SMTP_Host";SMTP_Host (vlSMTP_ID;[Constants]AccountSMPT_Server;0))))
			: (Not(ERRCHECK ("SMTP_From";SMTP_From (vlSMTP_ID;[Constants]CompanyName+" "+[Constants]CompanyEmail))))
			: (Not(ERRCHECK ("SMTP_Sender";SMTP_Sender (vlSMTP_ID;[Constants]EmailFrom;1))))
			: (Not(ERRCHECK ("SMTP_ReplyTo";SMTP_ReplyTo (vlSMTP_ID;[Constants]ReplyToEmail;1))))
			: (Not(ERRCHECK ("SMTP_Auth";SMTP_Auth (vlSMTP_ID;[Constants]AccountEmailAddress;[Constants]AccountEmailPassword))))
			: (Not(ERRCHECK ("SMTP_To";SMTP_To (vlSMTP_ID;[Customers]email;1))))
			: (Not(ERRCHECK ("SMTP_Cc";SMTP_Cc (vlSMTP_ID;[Customers]EmailCopy))))
			: (Not(ERRCHECK ("SMTP_Bcc";SMTP_Bcc (vlSMTP_ID;[Constants]BccEmailAddress))))
			: (Not(ERRCHECK ("SMTP_Subject";SMTP_Subject (vlSMTP_ID;[Constants]EmailSubjectLineProposal+" "+[Customers]FirstName+" "+[Customers]LastName;0))))
			: (Not(ERRCHECK ("SMTP_Body";SMTP_Body (vlSMTP_ID;<>vtEmailBody;4))))
			: (Not(ERRCHECK ("SMTP_Attachment";SMTP_Attachment (vlSMTP_ID;Get 4D folder(Active 4D Folder)+[Constants]CompanyAbreviation+" Proposal.pdf";2;1))))
			: (Not(ERRCHECK ("SMTP_AdditionalAttachment";AddAdditionalAttachments )))
			: (Not(ERRCHECK ("SMTP_Send";SMTP_Send (vlSMTP_ID;0))))
		End case


You are trying to connect on port 587 (with implicit STARTLS).

Try using explicit SSL (TLS) on port 465

<code 4D>


</code 4D>

This works for us :
[]28247366;“Our internal smtp component”[/]

I use Amazon SES. I don’t have any calls to IT_SetPort (or IT_Set@ anything) in the database. I use

SMTP_Send ($msg;1) //1 is SSL option.


You are right.

4D IC smtp ssl (12) default port is 465.

Thank you both for your replies.

It turns out the SMTP username and password Amazon sent me actually did not work! I got a new SMTP username and password for my Amazon AWS IAM username and I no longer get the Authorization error. I wonder how that came about?

However, I now get a ‘Transaction Failed’ error on the SMTP_send command — everything else works since this is the last command — same error using explicit TLS or or STARTTLS. I’m having trouble finding any reference to methods for troubleshooting and correcting this error.

Any experience on this issue?

Thanks again.

Figured it out. It had to do with how I was telling Amazon who the email was “From”. They are very picky.


They are very picky.
They make sur their platform is not used for spamming…

I also advise you to configure SPF and DKIM to get your mail being sent and not marked as spam…
AWS has great documentation.