bash-shell-script-to-test-smtp-ses-credentials
sudo apt-get install mailutils
!/bin/bash
Set the SMTP server name and port number
SMTP_SERVER="email-smtp.us-east-1.amazonaws.com"
SMTP_PORT="587"
Set the sender email address and AWS SES username and password
SENDER_EMAIL="your-sender-email@example.com"
SES_USERNAME="AWS-SES-USERNAME"
SES_PASSWORD="AWS-SES-PASSWORD"
Set the recipient email address
RECIPIENT_EMAIL="recipient-email@example.com"
Test SMTP credentials using openssl and mailx
echo "Testing SMTP credentials..."
openssl s_client -connect $SMTP_SERVER:$SMTP_PORT -starttls smtp -crlf <<< "EHLO $SMTP_SERVER" > /dev/null
echo "HELO $SMTP_SERVER" | openssl s_client -starttls smtp -connect $SMTP_SERVER:$SMTP_PORT -crlf -quiet -ign_eof 2>&1 > /dev/null
Send a test email using mailx
echo "Sending a test email..."
echo "This is a test email" | mailx -v -r $SENDER_EMAIL -s "Test Email" -S smtp="$SMTP_SERVER:$SMTP_PORT" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="$SES_USERNAME" -S smtp-auth-password="$SES_PASSWORD" $RECIPIENT_EMAIL
echo "Test complete."
Top comments (0)