SMTP - send an email from terminal
Revision as of 10:13, 24 July 2021 by Pio2pio (talk | contribs) (Pio2pio moved page SMTP - send an email using telnet to SMTP - send an email from terminal)
You can send an email using native SMTP commands while connecting to a mail server using Telnet connection. In the script below text in bold are the commands followed a space then free form string appropriate to the preceding command.
telnet mail_server.domain.com 25 220 mail_server.domain.com Microsoft ESMTP MAIL Service, Version: 7.5.7601.17514 ready at Thu, 31 Mar 2016 13:53:42 +0100 helo 250 mail_server.domain.com Hello [172.31.1.1] mail from: username@example.co.uk <- this need to be valid address, otherwise you'll get:501 5.5.4 Invalid Address 250 2.1.0 username@example.co.uk....Sender OK rcpt to: username@example.co.uk 250 2.1.5 username@example.co.uk data 354 Start mail input; end with <CRLF>.<CRLF> from: Piotr to: me Subject: Test via telenet <- [enter] may also require a space test body test <- [enter] may also require a space . <-- the '.' dot is important as indicates EndOfMessage 250 2.6.0 <MAIL_SERkTgbLYluLCT0006cc2b@mail_server.domain.com> Queued mail for delivery quit
Depends on your mail server the commands need to be in upper cases like HELO etc, the above was tested using Microsoft implementation.