diff --git a/docs/my-website/docs/proxy/email.md b/docs/my-website/docs/proxy/email.md
index 62dfeccf7ab..2551f4359b1 100644
--- a/docs/my-website/docs/proxy/email.md
+++ b/docs/my-website/docs/proxy/email.md
@@ -2,12 +2,6 @@ import Image from '@theme/IdealImage';
# ✨ 📧 Email Notifications
-:::info
-
-This is an Enterprise only feature [Get in touch with us for a Free Trial](https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat)
-
-:::
-
Send an Email to your users when:
- A Proxy API Key is created for them
- Their API Key crosses it's Budget
@@ -38,6 +32,12 @@ That's it ! start your proxy
## Customizing Email Branding
+:::info
+
+Customizing Email Branding is an Enterprise Feature [Get in touch with us for a Free Trial](https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat)
+
+:::
+
LiteLLM allows you to customize the:
- Logo on the Email
- Email support contact
diff --git a/litellm/integrations/slack_alerting.py b/litellm/integrations/slack_alerting.py
index 9e35b4fc3d7..c822958d93f 100644
--- a/litellm/integrations/slack_alerting.py
+++ b/litellm/integrations/slack_alerting.py
@@ -41,10 +41,6 @@ class ProviderRegionOutageModel(BaseOutageModel):
# we use this for the email header, please send a test email if you change this. verify it looks good on email
LITELLM_LOGO_URL = "https://litellm-listing.s3.amazonaws.com/litellm_logo.png"
-EMAIL_LOGO_URL = os.getenv(
- "SMTP_SENDER_LOGO", "https://litellm-listing.s3.amazonaws.com/litellm_logo.png"
-)
-EMAIL_SUPPORT_CONTACT = os.getenv("EMAIL_SUPPORT_CONTACT", "support@berri.ai")
class LiteLLMBase(BaseModel):
@@ -1147,21 +1143,34 @@ Model Info:
return False
+ async def _check_if_using_premium_email_feature(
+ self,
+ premium_user: bool,
+ email_logo_url: Optional[str] = None,
+ email_support_contact: Optional[str] = None,
+ ):
+ from litellm.proxy.proxy_server import premium_user
+ from litellm.proxy.proxy_server import CommonProxyErrors
+
+ if premium_user is not True:
+ if email_logo_url is not None or email_support_contact is not None:
+ raise ValueError(
+ f"Trying to Customize Email Alerting\n {CommonProxyErrors.not_premium_user.value}"
+ )
+
async def send_key_created_email(self, webhook_event: WebhookEvent) -> bool:
from litellm.proxy.utils import send_email
if self.alerting is None or "email" not in self.alerting:
# do nothing if user does not want email alerts
return False
+ from litellm.proxy.proxy_server import premium_user, prisma_client
- # make sure this is a premium user
- from litellm.proxy.proxy_server import premium_user
- from litellm.proxy.proxy_server import CommonProxyErrors, prisma_client
-
- if premium_user != True:
- raise Exception(
- f"Trying to use Email Alerting on key creation\n {CommonProxyErrors.not_premium_user.value}"
- )
+ email_logo_url = os.getenv("SMTP_SENDER_LOGO", None)
+ email_support_contact = os.getenv("EMAIL_SUPPORT_CONTACT", None)
+ await self._check_if_using_premium_email_feature(
+ premium_user, email_logo_url, email_support_contact
+ )
event_name = webhook_event.event_message
recipient_email = webhook_event.user_email
@@ -1188,7 +1197,7 @@ Model Info:
"Trying to send email alert to no recipient", extra=webhook_event.dict()
)
email_html_content = f"""
-
+
Hi {recipient_email},
@@ -1223,7 +1232,7 @@ Model Info:
- If you have any questions, please send an email to {EMAIL_SUPPORT_CONTACT}
+ If you have any questions, please send an email to {email_support_contact}
Best,
The LiteLLM team
@@ -1254,6 +1263,14 @@ Model Info:
"""
from litellm.proxy.utils import send_email
+ from litellm.proxy.proxy_server import premium_user, prisma_client
+
+ email_logo_url = os.getenv("SMTP_SENDER_LOGO", None)
+ email_support_contact = os.getenv("EMAIL_SUPPORT_CONTACT", None)
+ await self._check_if_using_premium_email_feature(
+ premium_user, email_logo_url, email_support_contact
+ )
+
event_name = webhook_event.event_message
recipient_email = webhook_event.user_email
user_name = webhook_event.user_id
@@ -1266,7 +1283,7 @@ Model Info:
if webhook_event.event == "budget_crossed":
email_html_content = f"""
-
+
Hi {user_name},
@@ -1274,7 +1291,7 @@ Model Info:
API requests will be rejected until either (a) you increase your monthly budget or (b) your monthly usage resets at the beginning of the next calendar month.
- If you have any questions, please send an email to {EMAIL_SUPPORT_CONTACT}
+ If you have any questions, please send an email to {email_support_contact}
Best,
The LiteLLM team
diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py
index b01312478b6..b96c469ec09 100644
--- a/litellm/proxy/utils.py
+++ b/litellm/proxy/utils.py
@@ -1850,20 +1850,13 @@ async def send_email(receiver_email, subject, html):
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_port = int(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")
+ raise ValueError("Trying to use SMTP, but SMTP_SENDER_EMAIL is not set")
## EMAIL SETUP ##
email_message = MIMEMultipart()