Error in code send Email

Kalyan Chakravarthy kalyanchakravarthy at
Thu May 21 07:31:02 CEST 2009

Hi All,

import smtplib

 mail="abc at";
    msg = 'Some Text';

    smtp_server = smtplib.SMTP( 'mail.%s' % mail.split( '@' )[-1] )
        , [ mail ]
        , 'Subject: %s\n' % subject
            + 'To: %s\n' % mail
            + '\n'
            + msg

I am using above  code to send an Email, for this i am not installed any
SMTP setup my local , I just given import smtplib
and I am getting following error

showing error at
 *smtp_server = smtplib.SMTP( 'mail.%s' % mail.split( '@' )[-1] )* this line

can any one tell that how to give STMP server setup in my local and run
successfully the above code.

**Traceback (most recent call last):
  File "C:\Program
line 500, in __call__*groups)
  File "C:\Documents and Settings\desk\Desktop\apps\temp\",
line 129, in post
    smtp_server = smtplib.SMTP( 'mail.%s' % mail.split( '@' )[-1] )
  File "C:\Python26\lib\", line 239, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Python26\lib\", line 295, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "C:\Python26\lib\", line 273, in _get_socket
    return socket.create_connection((port, host), timeout)
AttributeError: 'module' object has no attribute 'create_connection'

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list