import React, { useState, useEffect } from "react"; import { Card, Text, Grid, Button, TextInput, TableCell, } from "@tremor/react"; import { Typography, message, Divider } from "antd"; import { serviceHealthCheck, setCallbacksCall } from "./networking"; import { EmailEventSettings } from "./email_events"; const { Title } = Typography; interface EmailSettingsProps { accessToken: string | null; premiumUser: boolean; alerts: any[]; } const EmailSettings: React.FC = ({ accessToken, premiumUser, alerts, }) => { const handleSaveEmailSettings = () => { if (!accessToken) { return; } let updatedVariables: Record = {}; alerts .filter((alert) => alert.name === "email") .forEach((alert) => { Object.entries(alert.variables ?? {}).forEach(([key, value]) => { const inputElement = document.querySelector(`input[name="${key}"]`) as HTMLInputElement; if (inputElement && inputElement.value) { updatedVariables[key] = inputElement?.value; } }); }); console.log("updatedVariables", updatedVariables); //filter out null / undefined values for updatedVariables const payload = { general_settings: { alerting: ["email"], }, environment_variables: updatedVariables, }; try { setCallbacksCall(accessToken, payload); } catch (error) { message.error("Failed to update alerts: " + error, 20); } message.success("Email settings updated successfully"); } return ( <>
Email Server Settings LiteLLM Docs: email alerts
{alerts .filter((alert) => alert.name === "email") .map((alert, index) => (
    {Object.entries(alert.variables ?? {}).map(([key, value]) => (
  • { premiumUser!= true && (key === "EMAIL_LOGO_URL" || key === "EMAIL_SUPPORT_CONTACT") ? ( ) : (
    {key}
    )} {/* Added descriptions for input fields */}

    {key === "SMTP_HOST" && (

    Enter the SMTP host address, e.g. `smtp.resend.com` Required *
    )} {key === "SMTP_PORT" && (
    Enter the SMTP port number, e.g. `587` Required *
    )} {key === "SMTP_USERNAME" && (
    Enter the SMTP username, e.g. `username` Required *
    )} {key === "SMTP_PASSWORD" && ( Required * )} {key === "SMTP_SENDER_EMAIL" && (
    Enter the sender email address, e.g. `sender@berri.ai` Required *
    )} {key === "TEST_EMAIL_ADDRESS" && (
    Email Address to send `Test Email Alert` to. example: `info@berri.ai` Required *
    ) } {key === "EMAIL_LOGO_URL" && (
    (Optional) Customize the Logo that appears in the email, pass a url to your logo
    ) } {key === "EMAIL_SUPPORT_CONTACT" && (
    (Optional) Customize the support email address that appears in the email. Default is support@berri.ai
    ) }

  • ))}
))}
); }; export default EmailSettings;