[perl-python] sending email

X

Xah Lee

# -*- 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='(e-mail address removed)';
toAddr='(e-mail address removed)';
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
 
D

Dan Perl

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

Jürgen Exner

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
 
Y

YYusenet

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

How can you complain about *Mail::Mailer* and *Mail::Send* when you
don't even know what they are?
 
C

Chris Mattern

YYusenet said:
Xah Lee wrote:
[snip]
The first two has glaring problems. I'm sorry i forgot what they
^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
^^^^
[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?"
 

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,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top