Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Feb 152012

Sending email using raw SMTP commands


You can send email(s) by connecting to your SMTP server, and using raw SMTP commands.

E.g. assume your SMTP is localhost, listening port 25, enter the commands in bold

# telnet localhost 25
Connected to localhost.localdomain.
Escape character is '^]'.
220 ESMTP Postfix (Ubuntu)
helo localhost
mail from: [email protected]
250 2.1.0 Ok
rcpt to: [email protected]
250 2.1.5 Ok
354 End data with .
This is a test mail

250 2.0.0 Ok: queued as BA2FD1DB96
221 2.0.0 Bye
Connection closed by foreign host.

Jul 082010

Test if local SMTP server is running


To test if a local SMTP server is running, you can try to ping the port 25

# echo -e "quit" | nc localhost 25
220 ubuntu ESMTP Postfix (Ubuntu)
221 2.0.0 Bye

If no SMTP server is listening

# echo -e "quit" | nc localhost 25
localhost.localdomain [] 25 (?) : Connection refused