SMTPlib question

Barry A. Warsaw bwarsaw at beopen.com
Thu Aug 24 18:30:31 EDT 2000


>>>>> "dgreco" ==   <dgreco at atlantic.net> writes:

    dgreco> Not sure if this is really a Python question or a sendmail
    dgreco> question. I have written a CGI that takes thousands of
    dgreco> email addresses in from a form and sends emails to them
    dgreco> using SMTPlib. Running it from the command-line, it takes
    dgreco> about 5 minutes per 1,000 addresses. Needless to say, as a
    dgreco> CGI, this won't work because the HTTP connection timeouts.
    dgreco> The script works fine for small numbers of addresses.

    dgreco> I imagine it takes so long because the SMTP server
    dgreco> (sendmail) it connects to verifies various info on the
    dgreco> email such as the domain for it. Is this why it is taking
    dgreco> so long? What can I do to fix this? I don't care about
    dgreco> verification of the email addresses in anyway- if there
    dgreco> are invalid domains/addresses, they can just get bounced.

It's very likely your MTA that's causing the performance problems.
There are a number of things you can try to do:

- switch to a faster MTA such as Postfix
- chunk up your recipients and open multiple connections to your smtpd
- turn off DSN or otherwise re-configure your MTA

You might look at some of the approaches I've taken in Mailman, but
I've essentially come to the conclusion that neither CGI scripts, nor
mail programs should ever directly hand-off messages to an smtpd.  As
you've noticed, CGIs can time out, but so can mail programs for some
MTAs (e.g. Postfix).

What I do in Mailman 2.0 is craft the message and drop it into a queue
file.  This can be done very quickly.  Then I have another process
walk through the queued messages and do the delivery.

-Barry




More information about the Python-list mailing list