Python Email

738
1
09-18-2018 12:08 PM
rajujee
New Contributor III

I am stuck at this script for the last 2 weeks. I am getting error as soon I moved this script to AGS (ArcGIS Sever 10.3).

I am using python v2.7.8. error result

 

C:\Temp >test.py

Traceback (most recent call last):

  File "C:\Temp\\test.py", line 27, in <module>

    server.starttls()

  File "E:\ArcGIS10.3\lib\smtplib.py", line 637, in starttls

    raise SMTPException("STARTTLS extension not supported by server.")

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Email-Local.py
# Created on: 2018-02-20
# Description:
# ---------------------------------------------------------------------------

# Import smtplib for the actual sending function
import smtplib

# Import the email modules we'll need
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText

fromaddr = "xxxx@ourdomain.ca"
toaddr = "myname@ourdomain.ca"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "The contents of " + "more details"
body = "Email body message - more details to be added "
msg.attach(MIMEText(body, 'plain'))


server = smtplib.SMTP('server name', port)
server.ehlo()
server.starttls()
server.ehlo()
#server.login("youremailusername", "password")
text = msg.as_string()
server.sendmail(fromaddr, toaddr, text)
server.quit()
0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

I am getting error as soon I moved this script to AGS (ArcGIS Sever 10.3).

You moved the script to ArcGIS Server 10.3 from where?  Another ArcGIS Server machine?  An ArcGIS Desktop machine?

Since this error is directly, and only, related to smtplib, I suggest you search the web (Stack Exchange/Overflow) for suggestions on resolving it.

0 Kudos