AnsweredAssumed Answered

Send Email

Question asked by jay.kapalczynski on Oct 6, 2016
Latest reply on Oct 7, 2016 by Scott.Fierro

I am trying to send an email via python after my script runs...I am referencing this web page

How to send email in Python via SMTPLIB


I put in my Gmail user and password, not the one below...and run it...that's all I changed.


I get this error...wondering if anyone has done this before or have any other examples on how to do this.

Traceback (most recent call last):
File "C:/Users/tjv36463/Desktop/BearCollar/Python Files/", line 62, in <module>
smtpserver = smtplib.SMTP("",587)
File "C:\Python27\ArcGISx6410.3\lib\", line 251, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python27\ArcGISx6410.3\lib\", line 311, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python27\ArcGISx6410.3\lib\", line 286, in _get_socket
return socket.create_connection((host, port), timeout)
File "C:\Python27\ArcGISx6410.3\lib\", line 571, in create_connection
raise err
error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions


import smtplib

to = ''
gmail_user = ''
gmail_pwd = 'yourpassword'
smtpserver = smtplib.SMTP("",587)
smtpserver.login(gmail_user, gmail_pwd)
header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:testing \n'
print header
msg = header + '\n this is test msg from \n\n'
smtpserver.sendmail(gmail_user, to, msg)
print 'done!'