ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-tutor
python-tutor
[Tutor] smtplib with yahoo smtp server
by Intercodes other posts by this author
Jan 31 2006 8:55AM messages near this date
Re: [Tutor] Exit a child thread using threading.Thread() object | Re: [Tutor] smtplib with yahoo smtp server
Hello everyone,

I am working with a registration system for my website in mod_python. I
needed to send mail to registered users for confirmation. Since I can't use
my ISP's smtp server, I used yahoo's smtp server and my yahoo username and
password  to connect and send mail using this script (see below). But I get
the following error.

"Traceback (most recent call last):
  File "mail.py", line 12, in ?
    session = smtplib.SMTP(smtpserver)
  File "/usr/lib/python2.4/smtplib.py", line 255, in __init__
    addr = socket.gethostbyname(socket.gethostname())
socket.gaierror: (-2, 'Name or service not known')
"

I got this script from some website I can't remember and just changed some
values to get it to work. Is is possible to send mail like this? Is there
any other easy way to do this?

Thanks for your time.
---------------------------

import smtplib

smtpserver = 'smtp.mail.yahoo.com'
AUTHREQUIRED = 1
smtpuser = 'intercodes@.[snip]..' **
smtppass = '[snip]'

RECIPIENTS = ['intercodes@[snip]']
SENDER = 'intercodes@[snip]'
mssg = "mod python"

session = smtplib.SMTP(smtpserver)*if* AUTHREQUIRED:
    session.login(smtpuser, smtppass)
smtpresult = session.sendmail(SENDER, RECIPIENTS, mssg)**


--
Intercodes
Attachments:
unknown1
unknown2
unknown3
unknown4

Thread:
Intercodes
Ewald Ertl
Ewald Ertl
Intercodes
Srinivas Iyyer
Kent Johnson
Srinivas Iyyer
Danny Yoo
Alan Gauld
Rinzwind
Danny Yoo
Hugo González Monteverde
Python
Intercodes
Ewald Ertl
Intercodes

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved