feat check SMTP_SENDER_EMAIL + put behind enterprise license

This commit is contained in:
Ishaan Jaff 2024-05-24 14:37:53 -07:00
parent 25abdbdcc2
commit fd5a7a738f
2 changed files with 16 additions and 4 deletions

View file

@ -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:

View file

@ -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