diff --git a/litellm/integrations/slack_alerting.py b/litellm/integrations/slack_alerting.py index f8c0d0b5fd..5f8f0ada6e 100644 --- a/litellm/integrations/slack_alerting.py +++ b/litellm/integrations/slack_alerting.py @@ -815,7 +815,6 @@ Model Info: payload = webhook_event.model_dump_json() email_event = { - "from": "support@alerts.litellm.ai", "to": recipient_email, "subject": event_name, "html": email_html_content, @@ -823,8 +822,6 @@ Model Info: headers = {"Content-type": "application/json"} response = await send_email( - sender_name=email_event["from"], - sender_email=email_event["from"], receiver_email=email_event["to"], subject=email_event["subject"], html=email_event["html"], @@ -879,6 +876,7 @@ Model Info: and alert_type == "budget_alerts" and user_info is not None ): + # only send budget alerts over Email await self.send_email_alert_using_smtp(webhook_event=user_info) if "slack" not in self.alerting: diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index b11c2d04e2..11470bcdae 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -1819,7 +1819,7 @@ async def _cache_user_row( return -async def send_email(sender_name, sender_email, receiver_email, subject, html): +async def send_email(receiver_email, subject, html): """ smtp_host, smtp_port, @@ -1829,10 +1829,24 @@ async def send_email(sender_name, sender_email, receiver_email, subject, html): sender_email, """ ## SERVER SETUP ## + from litellm.proxy.proxy_server import premium_user + from litellm.proxy.proxy_server import CommonProxyErrors + + # Check if user is premium - This is an Enterprise only Feature + if premium_user != True: + raise Exception( + f"Trying to use Email Alerting\n {CommonProxyErrors.not_premium_user.value}" + ) + # Done Checking + smtp_host = os.getenv("SMTP_HOST") smtp_port = os.getenv("SMTP_PORT", 587) # default to port 587 smtp_username = os.getenv("SMTP_USERNAME") smtp_password = os.getenv("SMTP_PASSWORD") + sender_email = os.getenv("SMTP_SENDER_EMAIL", None) + if sender_email is None: + raise Exception("Trying to use SMTP, but SMTP_SENDER_EMAIL is not set") + ## EMAIL SETUP ## email_message = MIMEMultipart() email_message["From"] = sender_email