Created
June 22, 2023 06:57
-
-
Save me-suzy/ed29d5240d26cbbb55ccb3ee59eb48b3 to your computer and use it in GitHub Desktop.
Python use Cpanel to send email by SMTP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**# 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