[ILUG] Programmatic mail sending with Postfix
philip.reynolds at rfc-networks.ie
Wed Apr 7 12:11:59 IST 2004
Colm Buckley <colm at tuatha.org> 30 lines of wisdom included:
> I investigated this in 2002, and was unable to find an easy way to make
> Postfix do this. In theory, all that is necessary is to drop files
> into Postfix's "maildrop" directory and then signal the queue runner.
> However, the maildrop directory contains files in a Postfix internal
> format rather than in RFC822 format.
> The approach to take would be to abstract the routines from postdrop
> which convert RFC822 files to internal files, and use these in your
> program. We decided that this would be more hassle than it's worth.
It's also not recommended as the Postfix internals could change at
The best way to do this is via SMTP pipelining:
220 XXXXX.rfc-networks.ie ESMTP Postfix
MAIL From: <philip.reynolds at XXXXXXXXXXXXXXX>
RCPT To: <test at XXXXXXXXXXXXXXX>
RCPT To: <philip.reynolds at XXXXXXXXXXXXXXX>
RCPT To: <john at XXXXXXXXXX>
RCPT To: <pat at XXXXXXXXXXXXXXX>
354 End data with <CR><LF>.<CR><LF>
Subject: Great good Marketing Gizmo!
Hello ... hello ... hello!
250 Ok: queued as 8A5445CE0
All of the server commands are preceded with the status number (e.g.
250, 354 etc.)
SMTP multi-line commands are specified by using a -
is all one response.
This is the most efficient method of sending mail via Postfix. If
your mails are all going to be unique, simply set up N SMTP
connection to send X number of mails (X will depend on your Postfix
In this instance postdrop is not your friend.
Philip Reynolds | RFC Networks Ltd.
philip.reynolds at rfc-networks.ie | +353 (0)1 8832063
http://people.rfc-networks.ie/~phil/ | www.rfc-networks.ie
More information about the ILUG