Created
June 1, 2020 17:58
-
-
Save boina-n/28049b2eb97167a357bf5da753161b5d to your computer and use it in GitHub Desktop.
Send email with bash in in TLS, SSL or in plain text
This file contains 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 | |
subject="Subject of my email" | |
txtmessage="This is the message I want to send" | |
username='mail@exemple.com' | |
password='************' | |
From="mail01@exemple.com" | |
rcpt='testemail5739230@yopmail.com' | |
from_name='N BOINA' | |
rcpt_name='Nicolas Hulot' | |
{ | |
sleep 0.3; | |
echo "EHLO $(echo $username | cut -d "@" -f 2 )" | |
sleep 0.3; | |
# Comment this line if you use smtp without authentication | |
echo "AUTH PLAIN $(echo -ne "\0$username\0$password" | base64)" | |
sleep 0.3; | |
## uncomment if using smtp without encryption with telnet | |
#echo "AUTH LOGIN" | |
#sleep 0.3; | |
#echo $(echo -ne $username | base64) && echo $username64 | |
#sleep 0.3; | |
#echo $(echo -ne "\0$username\0$password" | base64) | |
sleep 0.3; | |
echo "MAIL FROM:<$From>" | |
sleep 0.3; | |
echo "rcpt to:<$rcpt>" | |
sleep 0.3; | |
echo "DATA" | |
sleep 0.3 | |
echo "Subject: $subject" | |
sleep 0.3 | |
echo "MIME-Version: 1.0" | |
sleep 0.3 | |
echo "From: $from_name <$From>" | |
sleep 0.3 | |
echo "Content-Type: text/html; charset=”UTF-8″" | |
sleep 0.3 | |
echo "To: $rcpt_name <$rcpt>" | |
sleep 0.3 | |
echo "Content-Transfer-Encoding: quoted-printable" | |
sleep 0.3 | |
echo $txtmessage | |
sleep 0.3; | |
echo "." | |
sleep 0.3; | |
## uncomment one of the following line depending on the encryption mode you want to use. | |
#} | telnet smtp-relay.gmail.com 25 | |
#} | openssl s_client -starttls smtp -crlf -connect smtp-relay.gmail.com:587 | |
} | openssl s_client -crlf -connect smtp-relay.gmail.com:465 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment