Prolateral Consulting Ltd
Prolateral Consulting Ltd
Support
Support
Knowledgebase Articles
Help
Setup examples
Support

Prolateral offers primary and backup domain (DNS) services, with servers in key geographic locations providing the best service possible.

Problem

How do I set up outbound SMTP using Python?
How do I use outMail in Python?

Solution

The following example of code assumes you have already got a fully functional webserver and Python installed and working.

Example code outmail-python.py


from smtplib import SMTP
import datetime

debuglevel = 0
username = "me@example.com"
password = "password"

smtp = SMTP()
smtp.set_debuglevel(debuglevel)
smtp.connect('mxXXXXXX.smtp-engine.com', 25)
smtp.login(username, password)

from_addr = "My Name<me@example.com>"
to_addr = "foo@bar.com"

subj = "Test email"  
date = datetime.datetime.now().strftime( "%d/%m/%Y %H:%M" )

message_text = "Hello\nThis is a test email\n\n"

msg = "From: %s\nTo: %s\nSubject: %s\nDate: %s\n\n%s"%( from_addr, to_addr, subj, date, message_text )

smtp.sendmail(from_addr, to_addr, msg)  
smtp.quit()

Summary of server details

Outgoing server

mxXXXXXX.smtp-engine.com

As provided in your signup email.

Outgoing server protocol

SMTP

Outgoing server port

25, 465, 587, 2525 or 8025

Authentication Type

Basic Authentication, SSL and TLS supported

Username

As provided

Password

As provided

 

like it, love it, then share it. Share this article on social media.

Did you enjoy this article?

Disclaimer

The Origin of this information may be internal or external to Prolateral Consulting Ltd. Prolateral makes all reasonable efforts to verify this information. However, the information provided in this document is for your information only. Prolateral makes no explicit or implied claims to the validity of this information. Any trademarks referenced in this document are the property of their respective owners.