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

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