Last active
March 20, 2021 06:09
-
-
Save starx/e7801de23ee58861dea205175ec1276b to your computer and use it in GitHub Desktop.
Send mail using gmail and curl
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
email_file=$(tempfile) | |
# Compose message | |
echo "From: Earthlings <[email protected]>" >> $email_file | |
echo "To: Martians <[email protected]>" >> $email_file | |
echo "Subject: Helloooo world" >> $email_file | |
echo "Content-Type: text/plain; charset=\"utf8\"" >> $email_file | |
echo >> $email_file | |
echo "Hi! :)" >> $email_file | |
# Send the email | |
curl \ | |
--url 'smtps://smtp.gmail.com:465' \ | |
--ssl-reqd \ | |
--mail-from '[email protected]' \ | |
--mail-rcpt '[email protected]' \ | |
--upload-file $email_file \ | |
--user '[email protected]:supersecretpassword' | |
# Cleanup | |
rm -f $email_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment