Skip to content

Instantly share code, notes, and snippets.

@me-suzy
Created June 22, 2023 06:58
Show Gist options
  • Select an option

  • Save me-suzy/02cbf992dabd47b58e16bb29f418cb49 to your computer and use it in GitHub Desktop.

Select an option

Save me-suzy/02cbf992dabd47b58e16bb29f418cb49 to your computer and use it in GitHub Desktop.
Python sending email Cpanel smtp
#!/usr/bin/python
import sys
import smtplib
from_addr = 'sender@example.com'
to_addrs = ['recipient@example.com']
msg = """From: Sender
To: Recipient
Subject: This is the message subject
This is the message body.
"""
try:
s = smtplib.SMTP('localhost')
s.login('sender@example.com', 'password')
s.sendmail(from_addr, to_addrs, msg)
s.quit()
except smtplib.SMTPException:
print "Error:", sys.exc_info()[0]
@babblebit.net>@a2example.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment