smtp - Why can't I send a mail to myself using python smtplib? -


i using code taken here:

import smtplib  def prompt(prompt):     return raw_input(prompt).strip()  fromaddr = prompt("from: ") toaddrs  = prompt("to: ").split() print "enter message, end ^d (unix) or ^z (windows):"  # add from: , to: headers @ start! msg = ("from: %s\r\nto: %s\r\n\r\n"        % (fromaddr, ", ".join(toaddrs))) while 1:     try:         line = raw_input()     except eoferror:         break     if not line:         break     msg = msg + line  print "message length " + repr(len(msg))  server = smtplib.smtp('localhost') server.set_debuglevel(1) server.sendmail(fromaddr, toaddrs, msg) server.quit() 

i put gmail mail account in sender , in reciver error:

traceback (most recent call last):   file "c:/python27/smtpexample.py", line 24, in <module>     server = smtplib.smtp('localhost')   file "c:\python27\lib\smtplib.py", line 242, in __init__     (code, msg) = self.connect(host, port)   file "c:\python27\lib\smtplib.py", line 302, in connect      self.sock = self._get_socket(host, port, self.timeout)   file "c:\python27\lib\smtplib.py", line 277, in _get_socket     return socket.create_connection((port, host), timeout)   file "c:\python27\lib\socket.py", line 571, in create_connection     raise err error: [errno 10061] no connection made because target machine actively refused 

you're not running smtp server on machine.

see: no connection made because target machine actively refused it


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -