Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves #6625 - SMTP Server not requiring AUTH #8459

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/my-website/docs/proxy/config_settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,12 @@ router_settings:
| SLACK_DAILY_REPORT_FREQUENCY | Frequency of daily Slack reports (e.g., daily, weekly)
| SLACK_WEBHOOK_URL | Webhook URL for Slack integration
| SMTP_HOST | Hostname for the SMTP server
| SMTP_PASSWORD | Password for SMTP authentication
| SMTP_PASSWORD | Password for SMTP authentication (do not set if SMTP does not require auth)
| SMTP_PORT | Port number for SMTP server
| SMTP_SENDER_EMAIL | Email address used as the sender in SMTP transactions
| SMTP_SENDER_LOGO | Logo used in emails sent via SMTP
| SMTP_TLS | Flag to enable or disable TLS for SMTP connections
| SMTP_USERNAME | Username for SMTP authentication
| SMTP_USERNAME | Username for SMTP authentication (do not set if SMTP does not require auth)
| SPEND_LOGS_URL | URL for retrieving spend logs
| SSL_CERTIFICATE | Path to the SSL certificate file
| SSL_VERIFY | Flag to enable or disable SSL certificate verification
Expand Down
11 changes: 3 additions & 8 deletions litellm/proxy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2322,12 +2322,6 @@ async def send_email(receiver_email, subject, html):
if smtp_host is None:
raise ValueError("Trying to use SMTP, but SMTP_HOST is not set")

if smtp_username is None:
raise ValueError("Trying to use SMTP, but SMTP_USERNAME is not set")

if smtp_password is None:
raise ValueError("Trying to use SMTP, but SMTP_PASSWORD is not set")

# Attach the body to the email
email_message.attach(MIMEText(html, "html"))

Expand All @@ -2337,8 +2331,9 @@ async def send_email(receiver_email, subject, html):
if os.getenv("SMTP_TLS", "True") != "False":
server.starttls()

# Login to your email account
server.login(smtp_username, smtp_password) # type: ignore
# Login to your email account only if smtp_username and smtp_password are provided
if smtp_username and smtp_password:
server.login(smtp_username, smtp_password) # type: ignore

# Send the email
server.send_message(email_message)
Expand Down