Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > [perl-python] sending email

Reply
Thread Tools

[perl-python] sending email

 
 
Xah Lee
Guest
Posts: n/a
 
      01-29-2005
# -*- 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 Removed)';
toAddr='(E-Mail 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
--------------------
Xah
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://xahlee.org/PageTwo_dir/more.html

 
Reply With Quote
 
 
 
 
Dan Perl
Guest
Posts: n/a
 
      01-30-2005
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.


 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      01-30-2005
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


 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      01-30-2005
Jürgen Exner <(E-Mail Removed)> 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
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Chris Mattern
Guest
Posts: n/a
 
      01-30-2005
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?"
 
Reply With Quote
 
Steve Holden
Guest
Posts: n/a
 
      01-31-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get the correct email format when sending email using sqldatareader rote ASP .Net 8 04-17-2008 02:14 AM
problem sending mail: Sending the email to the following server failed Luke Java 2 03-15-2007 10:54 AM
pls help me when i sent mail, it vil sending twice instead of once ,am using java.mail,am sending my code.... shailajabtech@gmail.com Java 0 09-28-2006 06:38 AM
Sending email through Stored procedure Patrick ASP .Net 2 02-15-2005 08:29 AM
avoid sending pictures within email Zhang Weiwu (family name first) Firefox 1 09-11-2003 02:00 PM



Advertisments