SMTP server w/o using Twisted framework

S

_spitFIRE

Is it possible to run a SMTP server that sends mail to recipients
using standard libraries, without using twisted framework, and also
without using any relay server?
 
J

Jeff McNeil

If you just want to send mail, you should be able to use the standard
smtplib module (http://docs.python.org/lib/module-smtplib.html). If
your recipients are on the Internet, you would need to handle MX
resolution yourself.

I know you said you want to avoid a relay server, but it's probably
the best bet unless you control the SMTP infrastructure or are simply
sending messages locally. Otherwise, you'll probably need to also
implement queuing and retry logic (depending on your requirements).
There are also some warning lights that may go off and flag your mail
as spam if you're using a method like that...

-Jeff
 
S

_spitFIRE

If you just want to send mail, you should be able to use the standard
smtplib module (http://docs.python.org/lib/module-smtplib.html). If
your recipients are on the Internet, you would need to handle MX
resolution yourself.

How complicated is to handle the MX resolution by myself? I'm sorry
that I don't have a clue regarding that. Any pointers would be greatly
appreciated.
I know you said you want to avoid a relay server, but it's probably
the best bet unless you control the SMTP infrastructure or are simply
sending messages locally.

The problem is that with the scenario I'm faced with, I don't have any
reliable SMTP server that I can use. Hence, I though I will spawn my
own light-weight SMTP server that can send mails to the people I want,
on the Internet. But, from what you are saying it seems, it might not
be that light weight after all!
Otherwise, you'll probably need to also
implement queuing and retry logic (depending on your requirements).

Isn't there a library module that can help me implement all this?
There are also some warning lights that may go off and flag your mail
as spam if you're using a method like that...

-Jeff

Would you please fill me in with some pointers as to why my mail might
get flagged as spam? Would it be considered spam even if I've a valid
from address, and a proper message/subject? Does the spam filter also
rely on the sending server's DNS etc because of which you say it might
get flagged as spam?
 
J

Jeff McNeil

Inline...

How complicated is to handle the MX resolution by myself? I'm sorry
that I don't have a clue regarding that. Any pointers would be greatly
appreciated.

You could try pyDNS (http://pydns.sourceforge.net). You should simply
be able to call the 'DNS.mxlookup' function. The other option would
be twisted.names...
The problem is that with the scenario I'm faced with, I don't have any
reliable SMTP server that I can use. Hence, I though I will spawn my
own light-weight SMTP server that can send mails to the people I want,
on the Internet. But, from what you are saying it seems, it might not
be that light weight after all!

What about simply running an SMTP server on the machine running your
application? Is that a possible approach?
Isn't there a library module that can help me implement all this?

Not that I know of. The protocol is standard, the queuing and retry
logic, not so much. Someone else may know more than I, though.
 
S

_spitFIRE

You need to do a DNS MX lookup. There's nothing in the Python stdlib
which provides this functionality. There are several libraries available
which do this, though (Twisted among them ;). You can probably find them
with a little googling. Beyond that, the rules for processing MX records
are simple and it's not much work to pick the right host once you can do
the MX lookups.

Jean-Paul

Thanks for the pointer. However, as I said currently, I can't use
anything other than the standard libraries.
 
S

_spitFIRE

You could try pyDNS (http://pydns.sourceforge.net). You should simply
be able to call the 'DNS.mxlookup' function. The other option would
be twisted.names...

Thanks for the pointers.
What about simply running an SMTP server on the machine running your
application? Is that a possible approach?

I guess that would be my last resort :)
Not that I know of. The protocol is standard, the queuing and retry
logic, not so much. Someone else may know more than I, though.

I understand what you are saying. I guess, I would fall back to my
last option!

Thanks, once again.
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

_spitFIRE said:
[looking up DNS MX records]
Thanks for the pointer. However, as I said currently, I can't use
anything other than the standard libraries.

Sure you can. You just need to get rid of the "only standard library"
requirement rule.

That works best by showing the alternatives to whoever set that requirement:

- use pyDNS
- use an existing (probably non-Python) SMTP daemon
- reimplement some parts of pyDNS yourself and develop a basic (crappy)
SMTP daemon yourself

For doing the latter, you should budget at least one week.

FWIW another reason why SMTP servers should retry on temporary failure
is that increasing use of Greylisting (*), which was precisely designed
to filter out mail from "crappy" servers, like botnets, and - well -
cheap custom written ones ;-)

-- Gerhard


(*) http://en.wikipedia.org/wiki/Greylisting - I use it myself
 
S

Steve Holden

Gerhard said:
_spitFIRE said:
[looking up DNS MX records]
Thanks for the pointer. However, as I said currently, I can't use
anything other than the standard libraries.

Sure you can. You just need to get rid of the "only standard library"
requirement rule.

That works best by showing the alternatives to whoever set that requirement:

- use pyDNS
- use an existing (probably non-Python) SMTP daemon
- reimplement some parts of pyDNS yourself and develop a basic (crappy)
SMTP daemon yourself

For doing the latter, you should budget at least one week.

FWIW another reason why SMTP servers should retry on temporary failure
is that increasing use of Greylisting (*), which was precisely designed
to filter out mail from "crappy" servers, like botnets, and - well -
cheap custom written ones ;-)
I'd actually use dnspython in preference to pyDNS, it's very easy to
use. I have some MX-server lookup code somewhere in the vault, if you
can use an external library.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
 
S

Steve Holden

Gerhard said:
_spitFIRE said:
[looking up DNS MX records]
Thanks for the pointer. However, as I said currently, I can't use
anything other than the standard libraries.

Sure you can. You just need to get rid of the "only standard library"
requirement rule.

That works best by showing the alternatives to whoever set that requirement:

- use pyDNS
- use an existing (probably non-Python) SMTP daemon
- reimplement some parts of pyDNS yourself and develop a basic (crappy)
SMTP daemon yourself

For doing the latter, you should budget at least one week.

FWIW another reason why SMTP servers should retry on temporary failure
is that increasing use of Greylisting (*), which was precisely designed
to filter out mail from "crappy" servers, like botnets, and - well -
cheap custom written ones ;-)
I'd actually use dnspython in preference to pyDNS, it's very easy to
use. I have some MX-server lookup code somewhere in the vault, if you
can use an external library.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
 

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
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top