/ Python

Test emails

With python's smtplib

#!/usr/bin/env python3

import smtplib

# email_dest = test@company.com
# email_host = smtp@company.com # Local domain
email_host = 'smtp.mailtrap.io'
email_host_user = '*********'
email_host_password = '*********'
# email_port = '587' # Default TLS
email_port = '2525' # mailtrap.io

smtpserver = smtplib.SMTP(email_host ,email_port)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(email_host_user, email_host_password)

header = 'To:' + email_dest + '\n' + 'From: ' + email_dest + '\n' + 'Subject:Test email \n'
email = header + '\n This is a python test email using smtplib\n'
print(msg)

smtpserver.sendmail(email_host_user, email_host_password, email)
smtpserver.close()
Test emails
Share this