<br clear="all">Hello everyone,<br><br>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.
<br><br>"Traceback (most recent call last):<br> File "mail.py", line 12, in ?<br> session = smtplib.SMTP(smtpserver)<br> File "/usr/lib/python2.4/smtplib.py", line 255, in __init__<br> addr =
socket.gethostbyname(socket.gethostname())<br>socket.gaierror: (-2, 'Name or service not known')<br>"<br><br>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?
<br><br>Thanks for your time.<br>---------------------------<br>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Kate, the KDE Advanced Text Editor">
<pre><span style="color: rgb(255, 0, 255);">import</span> smtplib
smtpserver <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(221, 0, 0);">'<a href="http://smtp.mail.yahoo.com">smtp.mail.yahoo.com</a>'</span>
AUTHREQUIRED <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(0, 0, 255);">1</span> <span style="color: rgb(128, 128, 128);"></span><br>smtpuser <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(221, 0, 0);">
'intercodes@.[snip]..'</span> <span style="color: rgb(128, 128, 128);"><i></i></span>
smtppass <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(221, 0, 0);">'[snip]'</span> <span style="color: rgb(128, 128, 128);"></span>
RECIPIENTS <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(255, 0, 255);">[</span><span style="color: rgb(221, 0, 0);">'intercodes@[snip]'</span><span style="color: rgb(255, 0, 255);">]</span>
SENDER <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(221, 0, 0);">'intercodes@[snip]'</span>
mssg <span style="color: rgb(255, 0, 255);">=</span> <span style="color: rgb(221, 0, 0);">"mod python"</span>
session <span style="color: rgb(255, 0, 255);">=</span> smtplib.SMTP<span style="color: rgb(255, 0, 255);">(</span>smtpserver<span style="color: rgb(255, 0, 255);">)</span>
<b>if</b> AUTHREQUIRED<span style="color: rgb(255, 0, 255);">:</span>
session.login<span style="color: rgb(255, 0, 255);">(</span>smtpuser, smtppass<span style="color: rgb(255, 0, 255);">)</span>
smtpresult <span style="color: rgb(255, 0, 255);">=</span> session.sendmail<span style="color: rgb(255, 0, 255);">(</span>SENDER, RECIPIENTS, mssg<span style="color: rgb(255, 0, 255);">)</span><b></b></pre><br>-- <br>Intercodes
<br>