-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
823 additions
and
802 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
import os | ||
import smtplib | ||
from email.mime.text import MIMEText | ||
from email.mime.multipart import MIMEMultipart | ||
from email.mime.text import MIMEText | ||
|
||
|
||
def send_email(subject, body_text, sender, receipients): | ||
# Create message content | ||
message = MIMEMultipart("alternative") | ||
message["Subject"] = subject | ||
message["From"] = sender | ||
# Create message content | ||
message = MIMEMultipart("alternative") | ||
message["Subject"] = subject | ||
message["From"] = sender | ||
|
||
if len(receipients) == 1: | ||
message["To"] = receipients[0] | ||
else: | ||
message["To"] = ", ".join(receipients) | ||
if len(receipients) == 1: | ||
message["To"] = receipients[0] | ||
else: | ||
message["To"] = ", ".join(receipients) | ||
|
||
# Add plain text part | ||
part1 = MIMEText(body_text, "plain") | ||
message.attach(part1) | ||
# Add plain text part | ||
part1 = MIMEText(body_text, "plain") | ||
message.attach(part1) | ||
|
||
# Add additional parts for HTML, attachments, etc. (optional) | ||
# Add additional parts for HTML, attachments, etc. (optional) | ||
|
||
# Connect to SMTP server | ||
with smtplib.SMTP_SSL(os.getenv('SES_HOST'), os.getenv('SES_PORT')) as server: # type: ignore | ||
server.login(os.getenv('USERNAME_SMTP'), os.getenv('PASSWORD_SMTP')) # type: ignore | ||
server.sendmail(sender, receipients, message.as_string()) | ||
# Connect to SMTP server | ||
with smtplib.SMTP_SSL(os.getenv('SES_HOST'), os.getenv('SES_PORT')) as server: # type: ignore | ||
server.login(os.getenv('USERNAME_SMTP'), os.getenv('PASSWORD_SMTP')) # type: ignore | ||
server.sendmail(sender, receipients, message.as_string()) | ||
|
||
return "Email sent successfully!" | ||
return "Email sent successfully!" |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.