43 points | by 21sys a day ago ago
5 comments
I use this in all the various little bash scripts I have running via timers. I love curl.
local email_body=$(cat <<- PANCAKE From: ${SMTP_FROM} To: ${SMTP_TO} Subject: BACKUP SCRIPT FAILED $0 backup script failed on ${HOSTNAME} Exit code: ${exit_code} Failed at line: ${line_number} $(journalctl -o cat --user _SYSTEMD_INVOCATION_ID=${invocation_id} || true) PANCAKE ) ## TODO: see above # Send email via authenticated SMTP using curl echo "${email_body}" | curl -s --url "${SMTP_URL}" \ --ssl-reqd \ --mail-from "${SMTP_FROM}" \ --mail-rcpt "${SMTP_TO}" \ --user "${SMTP_USERNAME}:${SMTP_PASSWORD}" \ --upload-file - }
According to Zawinski’s law, I expect curl to implement IMAP before long.
(Checks docs)
Oh.
Interesting and good to be aware of
When on a random CLI though my personal preference though is still to use telnet as the commands are easily memorized and there’s something more natural about typing the email out and then sending it.
me too, but more and more relays enforce tls or startssl (which is good!) and that's where telnet isn't a good fit imho.
I came across curl when I tested the mailgun.com smtp relay (mandatory tls + auth) and it worked immediately.
If you really want to do things manually, like telnet but with ssl, see OpenSSLs sclient:
openssl s_client -connect my.mailserver.com:465
I use this in all the various little bash scripts I have running via timers. I love curl.
According to Zawinski’s law, I expect curl to implement IMAP before long.
(Checks docs)
Oh.
Interesting and good to be aware of
When on a random CLI though my personal preference though is still to use telnet as the commands are easily memorized and there’s something more natural about typing the email out and then sending it.
me too, but more and more relays enforce tls or startssl (which is good!) and that's where telnet isn't a good fit imho.
I came across curl when I tested the mailgun.com smtp relay (mandatory tls + auth) and it worked immediately.
If you really want to do things manually, like telnet but with ssl, see OpenSSLs sclient: