Python email question

08-05-2019 01:58 PM
New Contributor II

I am trying to send a email using the smtplib package and am getting the following error:


  1. import smtplib
  2. server_ssl = smtplib.SMTP_SSL('', xxx)
  3. server_ssl.ehlo() # optional, called by login()
  4. server_ssl.login('xxxx@xxx.local', 'xx')
  5. # ssl server doesn't support or need tls, so don't call server_ssl.starttls()
  6. server_ssl.sendmail("", "", "hello")
  7. #server_ssl.quit()
  8. server_ssl.close()
  9. print 'successfully sent the mail'


Traceback (most recent call last):
File "", line 3, in <module>
server_ssl = smtplib.SMTP_SSL('', xxx)
File "C:\Python27\ArcGIS10.7\lib\", line 802, in __init__
SMTP.__init__(self, host, port, local_hostname, timeout)
File "C:\Python27\ArcGIS10.7\lib\", 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! #

Tags (2)
0 Kudos
1 Reply
by Anonymous User
Not applicable


Refer the following sample code which might be helpful for you. 

#system Modules

import httplib

import smtplib

from email.MIMEText import MIMEText

# script

host = ""

fromAdd = "fromemailaddress_Admin"

toAdd = "Your email address"

msg = MIMEText(stringInput)

msg['Subject'] = "Subject"

msg['From'] = fromAdd

msg['To'] = toAdd

s = smtplib.SMTP()


s.sendmail(fromAdd, msg["To"].split(","), msg.as_string())


0 Kudos