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/ImportBearDataFiles_TestForExcel.py", line 62, in <module>
smtpserver = smtplib.SMTP("smtp.gmail.com",587)
File "C:\Python27\ArcGISx6410.3\lib\smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python27\ArcGISx6410.3\lib\smtplib.py", line 311, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python27\ArcGISx6410.3\lib\smtplib.py", line 286, in _get_socket
return socket.create_connection((host, port), timeout)
File "C:\Python27\ArcGISx6410.3\lib\socket.py", 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
<SPAN class="keyword token">import</SPAN> smtplib
to <SPAN class="operator token">=</SPAN> <SPAN class="string token"><A class="jive-link-email-small" href="mailto:'mkyong2002@yahoo.com" rel="nofollow noopener noreferrer" target="_blank">'mkyong2002@yahoo.com</A><SPAN>'</SPAN></SPAN>
gmail_user <SPAN class="operator token">=</SPAN> <SPAN class="string token"><A class="jive-link-email-small" href="mailto:'mkyong2002@gmail.com" rel="nofollow noopener noreferrer" target="_blank">'mkyong2002@gmail.com</A><SPAN>'</SPAN></SPAN>
gmail_pwd <SPAN class="operator token">=</SPAN> <SPAN class="string token">'yourpassword'</SPAN>
smtpserver <SPAN class="operator token">=</SPAN> smtplib<SPAN class="punctuation token">.</SPAN>SMTP<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"smtp.gmail.com"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">587</SPAN><SPAN class="punctuation token">)</SPAN>
smtpserver<SPAN class="punctuation token">.</SPAN>ehlo<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
smtpserver<SPAN class="punctuation token">.</SPAN>starttls<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
smtpserver<SPAN class="punctuation token">.</SPAN>ehlo
smtpserver<SPAN class="punctuation token">.</SPAN>login<SPAN class="punctuation token">(</SPAN>gmail_user<SPAN class="punctuation token">,</SPAN> gmail_pwd<SPAN class="punctuation token">)</SPAN>
header <SPAN class="operator token">=</SPAN> <SPAN class="string token">'To:'</SPAN> <SPAN class="operator token">+</SPAN> to <SPAN class="operator token">+</SPAN> <SPAN class="string token">'\n'</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">'From: '</SPAN> <SPAN class="operator token">+</SPAN> gmail_user <SPAN class="operator token">+</SPAN> <SPAN class="string token">'\n'</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">'Subject:testing \n'</SPAN>
<SPAN class="keyword token">print</SPAN> header
msg <SPAN class="operator token">=</SPAN> header <SPAN class="operator token">+</SPAN> <SPAN class="string token">'\n this is test msg from mkyong.com \n\n'</SPAN>
smtpserver<SPAN class="punctuation token">.</SPAN>sendmail<SPAN class="punctuation token">(</SPAN>gmail_user<SPAN class="punctuation token">,</SPAN> to<SPAN class="punctuation token">,</SPAN> msg<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">'done!'</SPAN>
smtpserver<SPAN class="punctuation token">.</SPAN>close<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>