Skip to content

Instantly share code, notes, and snippets.

@me-suzy
Created June 22, 2023 06:57
Show Gist options
  • Save me-suzy/ed29d5240d26cbbb55ccb3ee59eb48b3 to your computer and use it in GitHub Desktop.
Save me-suzy/ed29d5240d26cbbb55ccb3ee59eb48b3 to your computer and use it in GitHub Desktop.
Python use Cpanel to send email by SMTP
**# Sending email with Cpanel by SMTP**
import sys
import smtplib
from_addr = 'YOUR EMAIL ADRESS'
to_addrs = ['YOUR EMAIL ADRESS']
msg = """From: Sender
To: Recipient
Subject: Okazii
The messsage here.
"""
try:
s = smtplib.SMTP('mail.YOUR-WEBSITE.COM', 465) # put here your own SMTP PORT and hosting email ( can be also, 26 )
s.login('YOUR EMAIL ADRESS', 'PASSWORD') # do not use GMAIL !!
s.sendmail(from_addr, to_addrs, msg)
s.quit()
except smtplib.SMTPException:
print("Error: ", sys.exc_info()[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment