471,356 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,356 software developers and data experts.

SMTP server w/o using Twisted framework

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?

Jul 5 '07 #1
8 1567
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

On 7/5/07, _spitFIRE <ti**********@gmail.comwrote:
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?

--
http://mail.python.org/mailman/listinfo/python-list
Jul 5 '07 #2
On Jul 5, 1:34 pm, "Jeff McNeil" <j...@jmcneil.netwrote:
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?

Jul 5 '07 #3
Inline...

On 7/5/07, _spitFIRE <ti**********@gmail.comwrote:
On Jul 5, 1:34 pm, "Jeff McNeil" <j...@jmcneil.netwrote:
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.
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...
>
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!
What about simply running an SMTP server on the machine running your
application? Is that a possible approach?
>
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?
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.
>
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?
http://mtamark.space.net/draft-stump...tamark-04.html
http://en.wikipedia.org/wiki/Sender_Policy_Framework
--
http://mail.python.org/mailman/listinfo/python-list
Jul 5 '07 #4
On Jul 5, 2:21 pm, Jean-Paul Calderone <exar...@divmod.comwrote:
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.

Jul 5 '07 #5
On Jul 5, 2:37 pm, "Jeff McNeil" <j...@jmcneil.netwrote:
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!
http://mtamark.space.net/draft-stump...licy_Framework
--
http://mail.python.org/mailman/listinfo/python-list
Thanks, once again.

Jul 5 '07 #6
_spitFIRE wrote:
[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
Jul 6 '07 #7
Gerhard Häring wrote:
_spitFIRE wrote:
>[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 -------------
Jul 6 '07 #8
Gerhard Häring wrote:
_spitFIRE wrote:
>[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 -------------

Jul 6 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Curtis Ransom | last post: by
2 posts views Thread by Chris Pearson | last post: by
34 posts views Thread by antonyliu2002 | last post: by
1 post views Thread by fabrizio.viggiani | last post: by
1 post views Thread by NARSIREDDY | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.