Created
February 17, 2020 22:11
-
-
Save EricTendian/464a44a5874f985654d79609fd4885f8 to your computer and use it in GitHub Desktop.
Sending an HTML email with curl over SMTP
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 | |
cat << EOF > email.eml | |
From: "${MAIL_FROM_NAME}" <${MAIL_FROM_ADDRESS}> | |
To: "${MAIL_TO_NAME}" <${MAIL_TO_ADDRESS}> | |
Reply-To: "${MAIL_TO_NAME}" <${MAIL_TO_ADDRESS}> | |
Subject: ${MAIL_SUBJECT} | |
Content-Type: text/html; charset="utf-8" | |
Content-Transfer-Encoding: quoted-printable | |
EOF | |
python -m quopri << EOF >> email.eml | |
<html> | |
<body> | |
<p>BODY HERE</p> | |
</body> | |
</html> | |
EOF | |
curl --ssl-reqd "smtps://${MAIL_HOST}:${MAIL_PORT}" \ | |
--user "${MAIL_USERNAME}:${MAIL_PASSWORD}" \ | |
--mail-from "${MAIL_FROM_ADDRESS}" \ | |
--mail-rcpt "${MAIL_TO_ADDRESS}" \ | |
--upload-file email.eml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment