mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
feat check SMTP_SENDER_EMAIL + put behind enterprise license
This commit is contained in:
parent
25abdbdcc2
commit
fd5a7a738f
2 changed files with 16 additions and 4 deletions
|
@ -815,7 +815,6 @@ Model Info:
|
||||||
|
|
||||||
payload = webhook_event.model_dump_json()
|
payload = webhook_event.model_dump_json()
|
||||||
email_event = {
|
email_event = {
|
||||||
"from": "support@alerts.litellm.ai",
|
|
||||||
"to": recipient_email,
|
"to": recipient_email,
|
||||||
"subject": event_name,
|
"subject": event_name,
|
||||||
"html": email_html_content,
|
"html": email_html_content,
|
||||||
|
@ -823,8 +822,6 @@ Model Info:
|
||||||
headers = {"Content-type": "application/json"}
|
headers = {"Content-type": "application/json"}
|
||||||
|
|
||||||
response = await send_email(
|
response = await send_email(
|
||||||
sender_name=email_event["from"],
|
|
||||||
sender_email=email_event["from"],
|
|
||||||
receiver_email=email_event["to"],
|
receiver_email=email_event["to"],
|
||||||
subject=email_event["subject"],
|
subject=email_event["subject"],
|
||||||
html=email_event["html"],
|
html=email_event["html"],
|
||||||
|
@ -879,6 +876,7 @@ Model Info:
|
||||||
and alert_type == "budget_alerts"
|
and alert_type == "budget_alerts"
|
||||||
and user_info is not None
|
and user_info is not None
|
||||||
):
|
):
|
||||||
|
# only send budget alerts over Email
|
||||||
await self.send_email_alert_using_smtp(webhook_event=user_info)
|
await self.send_email_alert_using_smtp(webhook_event=user_info)
|
||||||
|
|
||||||
if "slack" not in self.alerting:
|
if "slack" not in self.alerting:
|
||||||
|
|
|
@ -1819,7 +1819,7 @@ async def _cache_user_row(
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
async def send_email(sender_name, sender_email, receiver_email, subject, html):
|
async def send_email(receiver_email, subject, html):
|
||||||
"""
|
"""
|
||||||
smtp_host,
|
smtp_host,
|
||||||
smtp_port,
|
smtp_port,
|
||||||
|
@ -1829,10 +1829,24 @@ async def send_email(sender_name, sender_email, receiver_email, subject, html):
|
||||||
sender_email,
|
sender_email,
|
||||||
"""
|
"""
|
||||||
## SERVER SETUP ##
|
## 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_host = os.getenv("SMTP_HOST")
|
||||||
smtp_port = os.getenv("SMTP_PORT", 587) # default to port 587
|
smtp_port = os.getenv("SMTP_PORT", 587) # default to port 587
|
||||||
smtp_username = os.getenv("SMTP_USERNAME")
|
smtp_username = os.getenv("SMTP_USERNAME")
|
||||||
smtp_password = os.getenv("SMTP_PASSWORD")
|
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 SETUP ##
|
||||||
email_message = MIMEMultipart()
|
email_message = MIMEMultipart()
|
||||||
email_message["From"] = sender_email
|
email_message["From"] = sender_email
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue