SMTP server w/o using Twisted framework

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • _spitFIRE

    #1

    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?

  • Jeff McNeil

    #2
    Re: SMTP server w/o using Twisted framework

    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 <timid.Gentoo@g mail.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?
    >
    --

    >

    Comment

    • _spitFIRE

      #3
      Re: SMTP server w/o using Twisted framework

      On Jul 5, 1:34 pm, "Jeff McNeil" <j...@jmcneil.n etwrote:
      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?

      Comment

      • Jeff McNeil

        #4
        Re: SMTP server w/o using Twisted framework

        Inline...

        On 7/5/07, _spitFIRE <timid.Gentoo@g mail.comwrote:
        On Jul 5, 1:34 pm, "Jeff McNeil" <j...@jmcneil.n etwrote:
        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?
        >


        Comment

        • _spitFIRE

          #5
          Re: SMTP server w/o using Twisted framework

          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.

          Comment

          • _spitFIRE

            #6
            Re: SMTP server w/o using Twisted framework

            On Jul 5, 2:37 pm, "Jeff McNeil" <j...@jmcneil.n etwrote:
            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.

            Comment

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

              #7
              Re: SMTP server w/o using Twisted framework

              _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

              Comment

              • Steve Holden

                #8
                Re: SMTP server w/o using Twisted framework

                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 -------------

                Comment

                • Steve Holden

                  #9
                  Re: SMTP server w/o using Twisted framework

                  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 -------------

                  Comment

                  Working...