Skip to content

Commit

Permalink
fix: not sending emails correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
junglesub committed Mar 22, 2024
1 parent 9879bf7 commit d667d0a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sendmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
msgFrom = Header(f'\'{os.getenv("EMAIL_SENDER_NAME")}\'', 'utf-8')
msgFrom.append(f'<{os.getenv("EMAIL_SENDER_EMAIL")}>', 'ascii')

# Make email MIME
msg = MIMEMultipart("alternative")
msg["Subject"] = f"{todayDate()[0]} 한동 뉴스레터"
msg["From"] = msgFrom

def send_email(smtp, to_user, html):
email = to_user["email"]
# Make email MIME
msg = MIMEMultipart("alternative")
msg["Subject"] = f"{todayDate()[0]} 한동 뉴스레터"
msg["From"] = msgFrom
msg["To"] = email
htmlMIME = MIMEText(html, "html")
msg.attach(htmlMIME)
Expand All @@ -54,7 +54,7 @@ def send_email(smtp, to_user, html):
smtp.login(os.getenv("SMTP_ID"), os.getenv("SMTP_PW")) # 아이디 비밀번호로 로그인
for user in mailing_list:
send_email(smtp, user, html)
time.sleep(1)
time.sleep(0.5)

# smtp = smtplib.SMTP('localhost')
# smtp.sendmail("test@example.com", "junglesubmarine@gmail.com", msg.as_string())

0 comments on commit d667d0a

Please sign in to comment.