Last active
November 18, 2024 16:14
-
-
Save devops-school/9ec9fb184dda51eaff921e87d258b8f5 to your computer and use it in GitHub Desktop.
Revisions
-
devops-school revised this gist
Feb 21, 2023 . 1 changed file with 48 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ #!/bin/bash # Set the SMTP server name and port number SMTP_SERVER="email-smtp.ap-south-1.amazonaws.com" SMTP_PORT="587" # Set the sender email address and AWS SES username and password SENDER_EMAIL="[email protected]" SES_USERNAME="XXXXXXXXXXX" SES_PASSWORD="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" # Set the recipient email address RECIPIENT_EMAIL="[email protected]" # Test SMTP credentials using openssl and telnet 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 echo "QUIT" | openssl s_client -starttls smtp -connect $SMTP_SERVER:$SMTP_PORT -crlf -quiet -ign_eof 2>&1 > /dev/null # Send a test email using telnet echo "Sending a test email..." { sleep 1 echo "EHLO $SMTP_SERVER" sleep 1 echo "AUTH LOGIN" sleep 1 echo -n "$SES_USERNAME" | base64 sleep 1 echo -n "$SES_PASSWORD" | base64 sleep 1 echo "MAIL FROM: <$SENDER_EMAIL>" sleep 1 echo "RCPT TO: <$RECIPIENT_EMAIL>" sleep 1 echo "DATA" sleep 1 echo "Subject: Test Email" echo "From: $SENDER_EMAIL" echo "To: $RECIPIENT_EMAIL" echo "This is a test email." echo "." sleep 1 echo "QUIT" } | openssl s_client -starttls smtp -connect $SMTP_SERVER:$SMTP_PORT -crlf -quiet -ign_eof 2>&1 > /dev/null echo "Test complete." -
devops-school created this gist
Feb 16, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ #!/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="[email protected]" SES_USERNAME="AWS-SES-USERNAME" SES_PASSWORD="AWS-SES-PASSWORD" # Set the recipient email address RECIPIENT_EMAIL="[email protected]" # 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."