Sending Email using examples From Tutorials

Gg Galvez gg.galvez at gmail.com
Sat Jan 27 21:23:53 EST 2018


I am having difficulty getting the python script to send an email to work. Here is the code I use from among a number of other examples which I used. The only changes I made were the email addresses, so I can see the result if it works. If you have any suggestions, please email your reply also to gg.galvez at gmail.com.

Python Script used:

import smtplib
server = smtplib.SMTP('localhost')
server.sendmail('gg77galvez at yahoo.com',
"""To: gg.galvez at gmail.com
From: gg77galvez at yahoo.com

Beware the Ides of March.
""")
server.quit()

when running this I get the following message. Please help:

Traceback (most recent call last):
  File "D:\ProgramDev\PythonDev\sendemail.py", line 3, in <module>
    server = smtplib.SMTP('localhost')
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 335, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 306, in _get_socket
    self.source_address)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 722, in create_connection
    raise err
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 713, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it



More information about the Python-list mailing list