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 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 <people@earth.com>" >> $email_file | |
echo "To: Martians <people@mars.com>" >> $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 'people@earth.com' \ | |
--mail-rcpt 'people@mars.com' \ | |
--upload-file $email_file \ | |
--user 'people@earth.com:supersecretpassword' | |
# Cleanup | |
rm -f $email_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment