Skip to content

Commit

Permalink
Switch from STARTTLS to full TLS for email
Browse files Browse the repository at this point in the history
  • Loading branch information
florianhofhammer committed Nov 8, 2023
1 parent 7f686ae commit 6526dae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ services:
volumes:
- ./config.json:/bot/config.json:ro
container_name: polybot
init: true
8 changes: 2 additions & 6 deletions src/spam.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import config
import smtplib
import ssl

from email.message import EmailMessage

import config


def send_mail(recipient, user_captcha):
# Create the email to send
Expand All @@ -14,12 +12,10 @@ def send_mail(recipient, user_captcha):
msg["Subject"] = "Verification code for polygl0ts Discord server"
msg.set_content(f'Hello {recipient}, your verification code is "{user_captcha}"!')

with smtplib.SMTP(
with smtplib.SMTP_SSL(
host=config.email.smtp_host, port=config.email.smtp_port
) as smtp_conn:
try:
# Want a secure connection - use STARTTLS
smtp_conn.starttls(context=ssl.create_default_context())
# Mail go brrrrr
smtp_conn.login(user=config.email.username, password=config.email.password)
smtp_conn.sendmail(
Expand Down

0 comments on commit 6526dae

Please sign in to comment.