reg mail sending without smtp module

Mike Meyer mwm at mired.org
Thu May 12 03:44:19 EDT 2005


praba kar <prabapython at yahoo.co.in> writes:
> In Php we can build a Mail Message by
> Mail_mime class and send this message by
> Mail::Factory's class send Method. Here Php
> doesn't use any smtp modules. Like that
> In Python I used email.Message class to
> build Mail Message and Now I am searching
> modules to send this message as mail.

Python isn't PHP. In python, the standard way to send a message is
with the smtp module. If you do an "import this" in a python
interpreter, it will tell you (among other things) "There should be
one-- and preferably only one --obvious way to do it." The smtp module
is that way. Since smtp is also how mail is sent around the internet,
this makes a lot of sense.

Now, the PHP mail command uses the system's sendmail binary (at least
on Unix). You can do that by hand using the subprocess module in 2.4,
or os.system or os.popen or something similar on earlier versions of
Python. All this really does is asks sendmail to put a message in the
queue from the command line, rather than via the smtp port. It's
probably slower than talking to the already running smtp daemon.

On Windows, the PHP mail command connects to an smtp server - which is
exactly what smtplib does.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list