SMTP server w/o using Twisted framework

Discussion in 'Python' started by _spitFIRE, Jul 5, 2007.

  1. _spitFIRE

    _spitFIRE Guest

    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?
    _spitFIRE, Jul 5, 2007
    #1
    1. Advertising

  2. _spitFIRE

    Jeff McNeil Guest

    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 <> wrote:
    > 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
    >
    Jeff McNeil, Jul 5, 2007
    #2
    1. Advertising

  3. _spitFIRE

    _spitFIRE Guest

    On Jul 5, 1:34 pm, "Jeff McNeil" <> wrote:
    > 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?
    _spitFIRE, Jul 5, 2007
    #3
  4. _spitFIRE

    Jeff McNeil Guest

    Inline...

    On 7/5/07, _spitFIRE <> wrote:
    > On Jul 5, 1:34 pm, "Jeff McNeil" <> wrote:
    > > 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-stumpf-dns-mtamark-04.html
    http://en.wikipedia.org/wiki/Sender_Policy_Framework

    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
    Jeff McNeil, Jul 5, 2007
    #4
  5. _spitFIRE

    _spitFIRE Guest

    On Jul 5, 2:21 pm, Jean-Paul Calderone <> wrote:
    > 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.
    _spitFIRE, Jul 5, 2007
    #5
  6. _spitFIRE

    _spitFIRE Guest

    On Jul 5, 2:37 pm, "Jeff McNeil" <> wrote:
    > 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-stum...en.wikipedia.org/wiki/Sender_Policy_Framework
    >
    > > --
    > >http://mail.python.org/mailman/listinfo/python-list


    Thanks, once again.
    _spitFIRE, Jul 5, 2007
    #6
  7. _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
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Jul 6, 2007
    #7
  8. _spitFIRE

    Steve Holden Guest

    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 -------------
    Steve Holden, Jul 6, 2007
    #8
  9. _spitFIRE

    Steve Holden Guest

    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 -------------
    Steve Holden, Jul 6, 2007
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Carter
    Replies:
    2
    Views:
    879
    Jp Calderone
    Dec 30, 2003
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    430
    Jean-Paul Calderone
    Jun 17, 2008
  3. Glyph
    Replies:
    0
    Views:
    164
    Glyph
    Dec 27, 2012
  4. Glyph
    Replies:
    0
    Views:
    140
    Glyph
    Apr 3, 2013
  5. Glyph
    Replies:
    0
    Views:
    40
    Glyph
    May 12, 2014
Loading...

Share This Page