# How to use # Make sure you install curl. By running curl -v to test it. # Provide your Gmail username and password and who you need to send email to. # For password it is not your Gmail password but it is App passwords https://support.google.com/mail/answer/185833. Please go to your Gmail account setting and create it. # chmod -R 777 send-email-gmail.com # ./send-email-gmail.com # Your Gmail username (email) (Required) SENDER_GMAIL_USERNAME= # Your App password (Required) SENDER_GMAIL_PASSWORD= # Email you want to send to (Required) SEND_TO= # Name of you want to send to (Optional) SEND_TO_NAME= # Create temporary email_temp.html for use it to store email html format and some information. # It's use internet message format as descript in RFC5322 https://tools.ietf.org/html/rfc5322 echo "To: $SEND_TO_NAME <$SEND_TO>" >> email_temp.html echo "Subject: Send HTML5 Email by Shell Script and Curl" >> email_temp.html echo "Content-Type: text/html; charset=\"utf8\"" >> email_temp.html # Add Some HTML5 Template Here cat << EOF | cat >> email_temp.html
You can embedded image. like this
Or you can use CSS (Inline and same page CSS only)
Contact Me. EOF curl --mail-from "$SEND_TO" --mail-rcpt "$SEND_TO" --ssl -u "$SENDER_GMAIL_USERNAME:$SENDER_GMAIL_PASSWORD" -T "email_temp.html" -k --anyauth smtps://smtp.gmail.com:465 # Clean Up email_temp.html rm email_temp.html