Skip to content

Commit

Permalink
do not require smtp login and starttls if there is no password/userna…
Browse files Browse the repository at this point in the history
…me provided (#641)
  • Loading branch information
MaverikMoody authored Feb 11, 2025
1 parent 2e8cbd0 commit 00ebe0f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ When configuring outgoing SMTP please consider the following:

Restrictions:
* no other provider like Mailgun or Sendgrid must be configured for this to work
* only supports StartTLS right now (you have to use the corresponding port)
* no anonymous SMTP is supported right now (you have to use a username/password to authenticate)
* For AWS SES `CANARY_ALERT_EMAIL_FROM_DISPLAY` should be in the format: `CANARY_ALERT_EMAIL_FROM_DISPLAY=CanaryAlert <[email protected]>`

The following settings have to be configured in `switchboard.env` for SMTP to work:
Expand Down
5 changes: 3 additions & 2 deletions canarytokens/channel_output_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ def smtp_send(
smtpmsg.attach(part2)

with smtplib.SMTP(smtp_server, smtp_port) as server:
server.starttls()
server.login(smtp_username, smtp_password)
if smtp_username is not None and smtp_password is not None:
server.starttls()
server.login(smtp_username, smtp_password)
server.sendmail(fromaddr, toaddr, smtpmsg.as_string())
except smtplib.SMTPException as e:
log.error("A smtp error occurred: %s - %s" % (e.__class__, e))
Expand Down

0 comments on commit 00ebe0f

Please sign in to comment.