There are a few legitimate times when you find a need to speak raw SMTP to send an email. Here’s some scripts I’ve used in the past to help with that task.
Let’s start with echo.sh:
#!/bin/sh sleep 1 echo HELO nothax.nu sleep 1 echo 'MAIL FROM:<email@example.com>' sleep 1 echo RCPT TO:$1 sleep 1 echo DATA sleep 1 `cat letter.txt` echo '.'
Inside letter.txt you’ll have:
From: "Test User" <firstname.lastname@example.org> To: <email@example.com> Subject: Something good... MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit LOL - Lots Of Love.
Then you call it and pipe it to nc with the smtp server on port 25:
./echo.sh firstname.lastname@example.org | nc gmail-smtp-in.l.google.com 25
Goodluck! Feel free to leave a comment below with feedback and corrections. Also if you found this helpful and would like occasional updates of things happening in this arena subscribe to the newsletter. Thanks!