Re: [Tutor] smtplib with yahoo smtp server

2006-02-01 Thread Ewald Ertl
Hi!

I made a copy of the source you posted.
I just got a problem as expected when doing the session.login()
because the access-data is invalid.
The connection via the smtplib.SMTP() could be established.

Perhaps there is something wrong with your namelookup.

Can you try a call in the interactive environment for
socket.gethostname()
or
socket.gethostbyname( socket.gethostname() )

Can you resolve the hostname smtp.mail.yahoo.com on a commandline?
e.g. nslookup smtp.mail.yahoo.com ?

Hope this can help you

Ewald


Intercodes wrote:
 
 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 http://smtp.mail.yahoo.com'
 AUTHREQUIRED = 1 
 smtpuser = 
 '[EMAIL PROTECTED]' //
 smtppass = '[snip]'  
 
 RECIPIENTS = ['[EMAIL PROTECTED]']
 SENDER = '[EMAIL PROTECTED]'
 mssg = mod python
 
 session = smtplib.SMTP(smtpserver)
 *if* AUTHREQUIRED:
 session.login(smtpuser, smtppass)
 smtpresult = session.sendmail(SENDER, RECIPIENTS, mssg)**
 
 
 -- 
 Intercodes
 
 
 
 
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] smtplib with yahoo smtp server

2006-02-01 Thread Ewald Ertl
Hi!



Intercodes wrote:
 Ewald,
 
  First off, thanks for stopping by.
 
 The connection via the smtplib.SMTP() could be established.
 
 
  I dont think so. I think it fails before the login().
 
 --
 ex= smtplib.SMTP('smtp.mail.yahoo.com http://smtp.mail.yahoo.com')
 Traceback (most recent call last):
   File stdin, line 1, in ?
   File /usr/lib/python2.4/smtplib.py, line 241, in __init__
 (code, msg) = self.connect(host, port)
   File /usr/lib/python2.4/smtplib.py, line 289, in connect
 for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
 socket.gaierror: (-2, 'Name or service not known')
 
 

Here you get a different Traceback than in the original post.

After digging in smtplib.py here ( Python 2.3.3 )

the call should be socket.getaddrinfo( smtp.mail.yahoo.com, 25, 0, 
socket.SOCK_STREAM );

which succeeds here at my installation.

How do you resolve your hostnames ( /etc/nsswitch.conf gives the order of 
hostname resolution )



   socket.gethostname()
 'linux'
 -
 
 socket.gethostbyname(socket.gethostname())
 Traceback (most recent call last):
   File stdin, line 1, in ?
 socket.gaierror: (-2, 'Name or service not known')

 -- 

This should resolve your own local hostname!
The socket.gethostbyname() is a call into a shared object of Python and this 
would use
( So think I ) the standard-Libraries for resolution.

Is linux a valid hostname?
Does ping linux succeed.

I still think, that this a name resolution error on your host.

HTH Ewald

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] smtplib with yahoo smtp server

2006-02-01 Thread Intercodes
Ewald,
 -- ex= smtplib.SMTP('smtp.mail.yahoo.com http://smtp.mail.yahoo.com
') Traceback (most recent call last): File stdin, line 1, in ? File /usr/lib/python2.4/smtplib.py, line 241, in __init__ (code, msg) = self.connect
(host, port) File /usr/lib/python2.4/smtplib.py, line 289, in connect for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): socket.gaierror: (-2, 'Name or service not known')
 I am sorry , that's a mistake on my part. This output corresponds to a typo input data. The error you saw previously was the original one (the one with error on line 255...). I corrected the typo while posting it ( ..I thought the error was same)
--the call should be 
socket.getaddrinfo( smtp.mail.yahoo.com, 25, 0, socket.SOCK_STREAM ); socket.getaddrinfo('
smtp.mail.yahoo.com',25,0,socket.SOCK_STREAM)[(2, 1, 6, '', ('216.136.173.18', 25))]--
How do you resolve your hostnames ( /etc/nsswitch.conf gives the order of hostname resolution )
My nssswitch.conf --passwd: compatgroup: compathosts: files dnsnetworks: files dnsservices: filesprotocols: files
rpc: filesethers: filesnetmasks: filesnetgroup: filespublickey: filesbootparams: filesautomount: files nisaliases: files-
This should resolve your own local hostname!The socket.gethostbyname
() is a call into a shared object of Python and this would use ( So think I ) the standard-Libraries for resolution.You totally lost me here :) -
Is linux a valid hostname?Does ping linux succeed.
I suppose not.linux:/srv/ # ping linuxping: unknown host linux--
-- Intercodes
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] smtplib with yahoo smtp server

2006-02-01 Thread Ewald Ertl
Hi!

Intercodes wrote:
 
 My nssswitch.conf
 --
 passwd: compat
 group:  compat
 
 hosts:  files dns
 networks:   files dns
 
 services:   files
 protocols:  files
 rpc:files
 ethers: files
 netmasks:   files
 netgroup:   files
 publickey:  files
 
 bootparams: files
 automount:  files nis
 aliases:files
 
  
 -
 

The system looks first in the /etc/hosts-File and when there is no match found, 
the
configured DNS would be requested.

 
 This should resolve your own local hostname!
 The socket.gethostbyname () is a call into a shared object of
 Python and this would use ( So think I ) the standard-Libraries for
 resolution.
 
 
 You totally lost me here :)
 -
 
 
 Is linux a valid hostname?
 Does ping linux succeed.
 
 
 I suppose not.
 
 linux:/srv/ # ping linux
 ping: unknown host linux
 --

Here, I think is a strange problem. You can not resolve your own hostname.
Is there no entry in /etc/hosts for linux with the IP-Address of your server?
If not, try to insert such an entry.

HTH Ewald

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] smtplib with yahoo smtp server

2006-02-01 Thread Intercodes
Ewald,Here, I think is a strange problem. You can not resolve your own hostname.
Is there no entry in /etc/hosts for linux with the IP-Address of your server?If not, try to insert such an entry.
Thanks for all your suggestions. I inserted my IP address for 'linux' into /etc/hosts. Now smtplib.SMTP() works. But the authentication fails. I tried all combinations of user/pass , but no joy.I tried using gmail (
smtp.gmail.com), but it too shows some TLS error or something.I ve searched google , but every script that is available for smtplib uses either sendmail or use their own/isp smtp server. None for connecting to yahoo/gmail/hotmail or other servers using authentication.
But anyway, ill try hotmail next. (If I can't get this smtp to work, I have to manually send mails to users :p, disastrous. ) Thanks for your time.-- Intercodes

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] smtplib with yahoo smtp server

2006-02-01 Thread Python
On Wed, 2006-02-01 at 18:51 +0530, Intercodes wrote:
 Received: by wproxy.gmail.com with SMTP id i23so141320wra for
 tutor@python.org; Wed, 01 Feb 2006 05:21:36 -0800 (PST)
 Received: by 10.65.228.15 with SMTP id f15mr63752qbr; Wed, 01 Feb 2006
 05:21:36 -0800 (PST)
 Received: by 10.65.100.11 with HTTP; Wed, 1 Feb 2006 05:21:36 -0800
 (PST)
 Message-ID:
 [EMAIL PROTECTED]

Intercodes, you are using a web interface to send your email.  Can you
get a normal (Evolution, Thunderbird, pine, etc.) email client to work
on your system.  If those do not work, your Python program probably
won't work either.

The errors you're getting appear to come from system config issues
rather than programming errors.

-- 
Lloyd Kvam
Venix Corp

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] smtplib with yahoo smtp server

2006-01-31 Thread Intercodes
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 = 
'[EMAIL PROTECTED]' 
smtppass = '[snip]'  

RECIPIENTS = ['[EMAIL PROTECTED]']
SENDER = '[EMAIL PROTECTED]'
mssg = mod python

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

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor