Created
September 17, 2020 20:01
-
-
Save UnixSage/21e6ce10ec6ed47a5ada3ace5e5505ce to your computer and use it in GitHub Desktop.
Send email via AWS SES from the command line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DOMAIN="example.com" | |
MAILFROM="cmdline@${DOMAIN}" | |
MAILTO="[email protected]" | |
SUBJECT="Amazon SES SMTP Test from ${HOSTNAME}" | |
USER="AWSKEY" | |
PASSWORD="AWSSMTPPASSWORD" | |
SMTPHOST="email-smtp.us-east-1.amazonaws.com:587" | |
EMAILFILE="/tmp/testemail.$$" | |
USER64=`echo -n ${USER} | openssl enc -base64` | |
PASSWORD64=`echo -n ${PASSWORD} | openssl enc -base64` | |
cat << EOT > ${EMAILFILE} | |
EHLO ${DOMAIN} | |
AUTH LOGIN | |
${USER64} | |
${PASSWORD64} | |
MAIL FROM: ${MAILFROM} | |
RCPT TO: ${MAILTO} | |
DATA | |
From: SESTEST <${MAILFROM}> | |
To: ${MAILTO} | |
Subject: ${SUBJECT} | |
This message was sent using the Amazon SES SMTP interface. | |
. | |
QUIT | |
EOT | |
openssl s_client -crlf -quiet -starttls smtp -connect ${SMTPHOST} < ${EMAILFILE} | |
rm ${EMAILFILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment