SES emails failed

0

My sandbox has been moved to production. But my email still failed to send out. The following is the script I used. Could you help to see what might be wrong? Thanks.

#!/bin/bash

SMTPUsername="AKIAXEU5JZXLU7VMPURD" SMTPPassword="xxxxxx" MAILFROM="kevinszhang@yahoo.com" RCPT="kevinszhang@yahoo.com" #RCPT="shiying_ling@yahoo.com" #RCPT="ooto@simulator.amazonses.com" SUBJECT='aws'

DATA="This is a test message from aws."

CONFIGSET="my-first-configuration-set"

echo "X-SES-CONFIGURATION-SET: $CONFIGSET"

Encode SMTP username and password using base64

EncodedSMTPUsername=$(echo -n "$SMTPUsername" | openssl enc -base64) EncodedSMTPPassword=$(echo -n "$SMTPPassword" | openssl enc -base64)

#X-SES-CONFIGURATION-SET: $CONFIGSET

Construct the email

Email="EHLO snsbay.net AUTH LOGIN $EncodedSMTPUsername $EncodedSMTPPassword MAIL FROM: $MAILFROM RCPT TO: $RCPT DATA X-SES-CONFIGURATION-SET: $CONFIGSET From: $MAILFROM To: $RCPT Subject: $SUBJECT MIME-Version: 1.0 Content-Type: text/plain; $DATA .

QUIT "

echo "$Email" | openssl s_client -crlf -quiet -connect email-smtp.us-west-1.amazonaws.com:465

#echo "$Email" | openssl s_client -crlf -quiet -starttls smtp -connect email-smtp.us-west-1.amazonaws.com:587

if [ $? -eq 0 ] then echo "success" exit 0 else echo "failed" exit 1 fi

asked 9 months ago217 views
4 Answers
0

Hello.

I thought your shell script would also work based on the samples provided in the documentation below.
Just to be sure, please try the sample shell script provided in the document below to see if it works.
https://docs.aws.amazon.com/ses/latest/dg/send-email-smtp-client-command-line.html#send-email-using-openssl

By the way, are there any error messages output when you run your shell script?
Also, check if the SMTP endpoint is correct and the SMTP user credentials are correct.

profile picture
EXPERT
answered 9 months ago
  • The script I am using is based on the URL you suggested.

  • Thank you for sharing your message. Judging from the message, I think the email was sent normally. Please check to see if it has been sent to your spam folder. https://docs.aws.amazon.com/ses/latest/dg/troubleshoot-smtp.html

    250 Ok MessageID
    MessageID is a unique string of characters that Amazon SES uses to identify a message.

  • Yahoo mail and Gmail have strict security, so it is possible that they are blocked. https://aws.amazon.com/jp/blogs/messaging-and-targeting/an-overview-of-bulk-sender-changes-at-yahoo-gmail/

  • I checked the trash but no email. Email bounced said failure to deliver it. I got the 250 Ok but then 451 timed out:

    Is it possible for you to send the message to me using the script I provide?

    250 Ok 250 Ok 354 End data with <CR><LF>.<CR><LF>

    250 Ok 01110191374bfd71-e5b9befc-e03e-4ea0-85c2-2010ea59ad3f-000000 451 4.4.2 Timeout waiting for data from client.

  • Thanks again for your clues. The issue is: how am I going to prevent the blocking of gmail/yahoo? Because I checked DNS setting already. Not sure what to do next.

0

Hello, The issue is likely due to a missing blank line between the "DATA" command and the email body, and another blank line between the email body and the "QUIT" command. Add these blank lines to properly format the email.

bash
#!/bin/bash

SMTPUsername="AKIAXEU5JZXLU7VMPURD"
SMTPPassword="xxxxxx"
MAILFROM="kevinszhang@yahoo.com"
RCPT="kevinszhang@yahoo.com"
SUBJECT='aws'
DATA="This is a test message from aws."
CONFIGSET="my-first-configuration-set"

EncodedSMTPUsername=$(echo -n "$SMTPUsername" | openssl enc -base64)
EncodedSMTPPassword=$(echo -n "$SMTPPassword" | openssl enc -base64)

Email="
EHLO (link unavailable)
AUTH LOGIN $EncodedSMTPUsername $EncodedSMTPPassword
MAIL FROM: $MAILFROM
RCPT TO: $RCPT
DATA

X-SES-CONFIGURATION-SET: $CONFIGSET
From: $MAILFROM
To: $RCPT
Subject: $SUBJECT
MIME-Version: 1.0
Content-Type: text/plain

$DATA

.
QUIT
"

echo "$Email" | openssl s_client -crlf -quiet -connect (link unavailable)

if [ $? -eq 0 ]; then
  echo "success"
  exit 0
else
  echo "failed"
  exit 1
fi

The script was missing blank lines between the "DATA" command and the email body, and between the email body and the "QUIT" command. Adding these blank lines should resolve the issue.

profile picture
EXPERT
answered 9 months ago
  • I did as you suggested but still not working.

0

The following is the output:

X-SES-CONFIGURATION-SET: my-first-configuration-set depth=2 C = US, O = Amazon, CN = Amazon Root CA 1 verify return:1 depth=1 C = US, O = Amazon, CN = Amazon RSA 2048 M01 verify return:1 depth=0 CN = email-smtp.us-west-1.amazonaws.com verify return:1 220 email-smtp.amazonaws.com ESMTP SimpleEmailService-d-ECHQAJO17 WGfBBnsLmMzFMqUTe62y 250-email-smtp.amazonaws.com 250-8BITMIME 250-AUTH PLAIN LOGIN 250 Ok 334 VXNlcm5hbWU6 334 UGFzc3dvcmQ6 235 Authentication successful. 250 Ok 250 Ok 354 End data with <CR><LF>.<CR><LF> 250 Ok 01110191374bfd71-e5b9befc-e03e-4ea0-85c2-2010ea59ad3f-000000 451 4.4.2 Timeout waiting for data from client. success

answered 9 months ago
0

yahoo.com has a "reject" DMARC policy, so you cannot send from SES using that domain because you are not authorized to verify the yahoo.com domain, as a user of Yahoo Mail

Enable VDM to see when messages bounce, and why. Otherwise, you may subscribe to the event stream and process the bounce events as best fits your architecture

AWS
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions