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:<firstname.lastname@example.org>' 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" <email@example.com> To: <firstname.lastname@example.org> 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 email@example.com | 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!