AnsweredAssumed Answered

Python Email

Question asked by ramjee on Sep 18, 2018
Latest reply on Sep 18, 2018 by bixb0012

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()

Outcomes