I am trying to send a email using the smtplib package and am getting the following error:
Script:
Error:
Traceback (most recent call last):
File "Script5.py", line 3, in <module>
server_ssl = smtplib.SMTP_SSL('smtp.office365.com', xxx)
File "C:\Python27\ArcGIS10.7\lib\smtplib.py", line 802, in __init__
SMTP.__init__(self, host, port, local_hostname, timeout)
File "C:\Python27\ArcGIS10.7\lib\smtplib.py", line 259, in __init__
raise SMTPConnectError(code, msg)
smtplib.SMTPConnectError: (-1, 'The Microsoft Exchange IMAP4 service is ready. [QgBOADYAUABSADEAMQBDAEEAMAAw]')
Any help is appreciated. Thank you! #
Hi,
Refer the following sample code which might be helpful for you.
#system Modules
import httplib
import smtplib
from email.MIMEText import MIMEText
# script
host = "xxxxx-xxxx.xxx"
fromAdd = "fromemailaddress_Admin"
toAdd = "Your email address"
msg = MIMEText(stringInput)
msg['Subject'] = "Subject"
msg['From'] = fromAdd
msg['To'] = toAdd
s = smtplib.SMTP()
s.connect(host)
s.sendmail(fromAdd, msg["To"].split(","), msg.as_string())
s.close()