[perl-python] sending email

Discussion in 'Perl Misc' started by Xah Lee, Jan 29, 2005.

  1. Xah Lee

    Xah Lee Guest

    # -*- coding: utf-8 -*-
    # Python

    # Suppose you want to spam your friend, and you have lots of
    # friends. The solution is to write a program to do it. After a gander
    # at python docs, one easily found the module for the job.
    # see http://python.org/doc/2.3.4/lib/SMTP-example.html

    # the code is a bit long with the command line, but the key lies at
    # the bottom four lines. The gist is this:

    import smtplib

    smtpServer='smtp.yourdomain.com';
    fromAddr='';
    toAddr='';
    text='''Subject: newfound love

    Hi friend,

    long time no write, i have a new manifesto i
    think it would be of interest for you to peruse.
    ....
    '''

    server = smtplib.SMTP(smtpServer)
    server.set_debuglevel(1)
    server.sendmail(fromAddr, toAddr, text)
    server.quit()


    # save this file as x.py and run it.
    # it should send out the mail.

    # the set_debuglevel() is nice because you see all the interactions
    # with the smtp server. Useful when you want to see what's going on
    # with a smtp server.
    -------------------------
    in Perl, there are not just one, two, or 3 modules that does the job,
    each with slight problems. Here's how the situation stands as of 2001
    March:

    For Perl libraries that deals with RFC 821, I personally know of
    three:

    * Mail::Mailer. Mentioned in most Perl books.
    Written or maintained by Graham Barr.

    * Mail::Send, maintained by Graham Barr , originally
    written by Tim Bunce.

    * Mail::Sendmail by Milivoj Ivkovic.

    The first two has glaring problems. I'm sorry i forgot what they
    are. I think Mail::Mailer has a bug on the from field. i.e. it ignores
    what you gave. I'm currently using Mail::Sendmail, and according to a
    ex-colleague, it has problems with some DNS mail exchange entries.

    for some discussion of the plethora of Perl mail modules and their
    short-cummings, see http://alma.ch/perl/mail.htm
    --------------------
    Xah

    http://xahlee.org/PageTwo_dir/more.html
     
    Xah Lee, Jan 29, 2005
    #1
    1. Advertising

  2. Xah Lee

    Dan Perl Guest

    I recommend the example in the Python Library Reference as a better example:
    http://www.python.org/doc/lib/SMTP-example.html. You can also find the
    entire description of the smtplib module in the same section
    (http://www.python.org/doc/lib/module-smtplib.html).

    Xah Lee's example is missing:
    - The login() call needed by SMTP hosts that require authentication.
    - The 'From:' and 'To:' addresses in the header of the email. They
    are not mandatory, but you would probably use them.
     
    Dan Perl, Jan 30, 2005
    #2
    1. Advertising

  3. Xah Lee wrote:
    [...]
    > Here's how the situation stands as of 2001 March:

    ^^^^^^^^^^

    Well, at least now we know why Mr. Lee is a little bit behind ....

    jue
     
    Jürgen Exner, Jan 30, 2005
    #3
  4. Jürgen Exner <> wrote:
    > Xah Lee wrote:
    > [...]
    >> Here's how the situation stands as of 2001 March:

    > ^^^^^^^^^^
    >
    > Well, at least now we know why Mr. Lee is a little bit behind ....



    Mr. Lee is a *big* behind!


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jan 30, 2005
    #4
  5. YYusenet wrote:

    > Xah Lee wrote:
    > [snip]
    >>
    >> The first two has glaring problems. I'm sorry i forgot what they

    > ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
    >> are.

    > ^^^^
    > [snip]
    >
    > How can you complain about *Mail::Mailer* and *Mail::Send* when you
    > don't even know what they are?
    >

    You know, I started to make fun of that, but then decided there was
    nothing I could say that it doesn't say for itself.

    --
    Christopher Mattern

    "Which one you figure tracked us?"
    "The ugly one, sir."
    "...Could you be more specific?"
     
    Chris Mattern, Jan 30, 2005
    #5
  6. Xah Lee

    Steve Holden Guest

    Chris Mattern wrote:

    > YYusenet wrote:
    >
    >
    >>Xah Lee wrote:
    >> [snip]
    >>
    >>>The first two has glaring problems. I'm sorry i forgot what they

    >>
    >> ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
    >>
    >>>are.

    >>
    >> ^^^^
    >> [snip]
    >>
    >>How can you complain about *Mail::Mailer* and *Mail::Send* when you
    >>don't even know what they are?
    >>

    >
    > You know, I started to make fun of that, but then decided there was
    > nothing I could say that it doesn't say for itself.
    >

    We interrupt this insanity, since followups were set to
    comp.lang.perl.misc, to ask whether any of the (clearly extremely
    tolerant) Perl users who didn't plonk this Xah Lee nonsense weeks ago
    might be interested in attending a Python conference - to be specific,
    PyCon, see http://www.pycon.org/. The conference took (some of) its
    inspiration from YAPC in terms of low cost and community involvement,
    and I'm sure there is still lots for us to learn from each other.

    Fraternally yours
    Steve Holden
    PyCon DC 2005 Chair
    --
    Steve Holden http://www.holdenweb.com/
    Python Web Programming http://pydish.holdenweb.com/
    Holden Web LLC +1 703 861 4237 +1 800 494 3119
     
    Steve Holden, Jan 31, 2005
    #6
    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. Xah Lee

    [perl-python] sending email

    Xah Lee, Jan 29, 2005, in forum: Python
    Replies:
    5
    Views:
    396
    Chris Mattern
    Jan 30, 2005
  2. Luke
    Replies:
    2
    Views:
    4,808
    Nigel Wade
    Mar 15, 2007
  3. rote
    Replies:
    8
    Views:
    796
  4. Lars Roland

    Sending email using perl

    Lars Roland, Nov 15, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    186
    Michele Dondi
    Nov 15, 2004
  5. Kevin B. Pease
    Replies:
    1
    Views:
    389
    A. Sinan Unur
    Nov 19, 2004
Loading...

Share This Page