python SMTP server

F

Fernando M.

Hi,
i made a test with smtplib module a few days ago, for sending mails,
and i was wondering if there's another module for running an SMTP
server, so i could make a standalone script for sending mails without
using an external SMTP server.
I've been searching but i'm not sure if there are modules for it, or
anything.
Which ones are my options?

Thanks.
 
C

Cliff Wells

Hi,
i made a test with smtplib module a few days ago, for sending mails,
and i was wondering if there's another module for running an SMTP
server, so i could make a standalone script for sending mails without
using an external SMTP server.
I've been searching but i'm not sure if there are modules for it, or
anything.
Which ones are my options?

You might take a look at:

http://www.divmod.org/projects/quotient

It does quite a bit more than just SMTP, but that is included.

However, you should note that if you are running the server at home,
chances are that most mail servers will reject mail from your system.
It's best to use the server your ISP provides. You can have your local
SMTP server forward through your ISP's server, but this is, in most
cases, unneeded complexity.

Regards,
Cliff
 
B

Benjamin Niemann

Fernando said:
Hi,
i made a test with smtplib module a few days ago, for sending mails,
and i was wondering if there's another module for running an SMTP
server, so i could make a standalone script for sending mails without
using an external SMTP server.
I've been searching but i'm not sure if there are modules for it, or
anything.
Which ones are my options?

An SMTP server is (simplified) a program that listens on port 25 for
incoming mails.

What you probably want to do is:
Do a DNS query for the recipent's domain and use smtplib to connect to the
server specified in the MX record. There was a module for DNS querie (not
in Python's stdlib), but I forgot how it was called or where you could find
it (try the Vaults of Parnassus or PyPI).

Or you may use an external tool like 'dig' ('dig mx DOMAIN').

But you should be aware of the fact that (if you send mail from a dialup
machine without going through a relay server) your mails will quickly be
marked as spam - I hope you do not intend to send spam...
 
C

Cliff Wells

But you should be aware of the fact that (if you send mail from a dialup
machine without going through a relay server) your mails will quickly be
marked as spam - I hope you do not intend to send spam...

Yah, Postfix on my servers uses several dnsbl's which automatically
reject home users (unless they authenticate first). Even if this isn't
the case for the majority of SMTP servers today I expect it won't be
long before it is.

As an aside, I will say that many SMTP servers that service home users
(i.e. Comcast, et al) limit the amount of mail that you can send within
a defined period. By using a local SMTP server to proxy, your app can
queue up a large amount of mail in a much shorter period. It won't
necessarily go out any faster, but at least your app won't be tied up
waiting for the mail to be accepted. So there is perhaps one useful
(beyond learning and fun) application for using a local SMTP server.

Regards,
Cliff
 
B

Benjamin Niemann

Cliff said:
Yah, Postfix on my servers uses several dnsbl's which automatically
reject home users (unless they authenticate first). Even if this isn't
the case for the majority of SMTP servers today I expect it won't be
long before it is.

As an aside, I will say that many SMTP servers that service home users
(i.e. Comcast, et al) limit the amount of mail that you can send within
a defined period.

Or completely block outgoing traffic on port 25 except to their own relay...
By using a local SMTP server to proxy, your app can
queue up a large amount of mail in a much shorter period. It won't
necessarily go out any faster, but at least your app won't be tied up
waiting for the mail to be accepted. So there is perhaps one useful
(beyond learning and fun) application for using a local SMTP server.

It would be interesting what the intention of the OP is. I just stumpled
upon a similar problem. The prog I'm currently working on has a function to
report crashes back to me. Originally these reports where sent by mail - no
problem on UNIX/Linux hosts where you can assume to have a working MDA on
localhost. But what to do on Windows systems?!? Ask for a SMTP server
during installation? Confusing as the program itself is totally unrelated
to email. In this case you _could_ deliver the mail directly to my MX
host... But instead of this I installed a small CGI on my website that
sends the mails to me and gets the data via HTTP POST from my app.
 
C

Cliff Wells

Cliff Wells wrote:

Or completely block outgoing traffic on port 25 except to their own relay...

Luckily I haven't encountered this with Comcast Cable (I use my own
mailserver [requires smtpauth] directly from home as Comcast seems to
have issues with mail and DNS on occasion). If I ever do, I'll
immediately switch to one of the local DSL providers who support Linux.
Better for MTA's to block dynamic/home IP's using dnsbls than have the
ISP limit what you can do with your home computer.
It would be interesting what the intention of the OP is. I just stumpled
upon a similar problem. The prog I'm currently working on has a function to
report crashes back to me. Originally these reports where sent by mail - no
problem on UNIX/Linux hosts where you can assume to have a working MDA on
localhost. But what to do on Windows systems?!? Ask for a SMTP server
during installation? Confusing as the program itself is totally unrelated
to email. In this case you _could_ deliver the mail directly to my MX
host... But instead of this I installed a small CGI on my website that
sends the mails to me and gets the data via HTTP POST from my app.

You can also use port redirection to bypass this sort of thing. Send on
port 10025 instead and direct your MTA to listen on both ports.

Regards,
Cliff
 
B

Benjamin Niemann

Cliff said:
Cliff Wells wrote:

[snip]
It would be interesting what the intention of the OP is. I just stumpled
upon a similar problem. The prog I'm currently working on has a function
to report crashes back to me. Originally these reports where sent by mail
- no problem on UNIX/Linux hosts where you can assume to have a working
MDA on localhost. But what to do on Windows systems?!? Ask for a SMTP
server during installation? Confusing as the program itself is totally
unrelated to email. In this case you _could_ deliver the mail directly to
my MX host... But instead of this I installed a small CGI on my website
that sends the mails to me and gets the data via HTTP POST from my app.

You can also use port redirection to bypass this sort of thing. Send on
port 10025 instead and direct your MTA to listen on both ports.
This would still be problematic with company firewall that block everything
but a handful of ports. Port 80 is still one of the safest bets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,311
Members
47,981
Latest member
satome

Latest Threads

Top