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

Answer:

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
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
220 smtp.example.com ESMTP Postfix (Ubuntu)
helo localhost
250 smtp.example.com
mail from: john@example.com
250 2.1.0 Ok
rcpt to: mary@example.com
250 2.1.5 Ok
data
354 End data with .
This is a test mail
.

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

Sep 082011
 

Show current Postfix queue listing

Answer:

To show the current Postfix queue, you can try the command "postqueue"

# postqueue -p

-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
BD7E2BF973      972 Sat Aug 27 08:57:54  no-reply@example.com
(connect to alt4.gmail-smtp-in.l.google.com[209.85.143.27]:25: Connection timed out)
                                         johndoe@gmail.com
Aug 312011
 

Debug and verify Postfix configurations

Answer:

A simple way to debug and verify your Postfix configurations is the use the sendmail command with the -bv flag.

Example:

# sendmail -bv username@example.com

No email will be sent using the above command, it just report after verifying each recipient address. This is very useful for testing the Postfix configurations.