diff --git a/pages/docs/configuration/authentication/email.mdx b/pages/docs/configuration/authentication/email.mdx index 883123a31..95899e9a8 100644 --- a/pages/docs/configuration/authentication/email.mdx +++ b/pages/docs/configuration/authentication/email.mdx @@ -1,6 +1,6 @@ --- title: Email setup -description: This guide explains how to configure the secure email verification/password reset. You can configure it to work with various email services, including Gmail and custom mail servers. +description: This guide explains how to configure the secure email verification/password reset. You can configure it to work with various email services, including Gmail, Mailgun, and custom mail servers. --- # Email verification and Password Reset @@ -9,6 +9,35 @@ For a quick overview, refer to the user guide provided here: [Password Reset](/d ## General setup +LibreChat supports multiple email providers: +- **Mailgun API** - Recommended for servers that block SMTP ports +- **SMTP Services** - Traditional email sending via Gmail, Outlook, or custom mail servers + +### Common Configuration + +These variables are used by both Mailgun and SMTP: + + + +### Mailgun Configuration (Recommended) + +Mailgun is particularly useful for deployments on servers that block SMTP ports to prevent spam. When both `MAILGUN_API_KEY` and `MAILGUN_DOMAIN` are set, LibreChat will use Mailgun instead of SMTP. + + + +### SMTP Configuration + **Basic Configuration** If you want to use one of the predefined services, configure only these variables: @@ -19,8 +48,6 @@ For more info about supported email services: https://community.nodemailer.com/2 ['EMAIL_SERVICE', 'string', 'Email service (e.g., Gmail, Outlook).','EMAIL_SERVICE='], ['EMAIL_USERNAME', 'string', 'Username for authentication.','EMAIL_USERNAME='], ['EMAIL_PASSWORD', 'string', 'Password for authentication.','EMAIL_PASSWORD='], - ['EMAIL_FROM_NAME', 'string', 'From name.','EMAIL_FROM_NAME='], - ['EMAIL_FROM', 'string', 'From email address. Required.','EMAIL_FROM=noreply@librechat.ai'], ]} /> @@ -39,7 +66,30 @@ If you want to use a generic SMTP service or need advanced configuration for one /> -**Failing to perform either of the below setups will result in LibreChat using the unsecured password reset! This allows anyone to reset any password on your server immediately, without mail being sent at all!** +**Failing to configure either Mailgun or SMTP properly will result in LibreChat using the unsecured password reset! This allows anyone to reset any password on your server immediately, without mail being sent at all!** + + +## Setup with Mailgun + +To set up Mailgun, follow these steps: + +1. Sign up for a Mailgun account at [mailgun.com](https://www.mailgun.com/) +2. Add and verify your domain in the Mailgun dashboard +3. Navigate to the API Keys section and copy your Private API key +4. In the `.env` file, modify the variables as follows: + + + + +If your Mailgun account is in the EU region, make sure to set `MAILGUN_HOST=https://api.eu.mailgun.net` ## Setup with Gmail @@ -80,3 +130,98 @@ To set up a custom mail server, follow these steps: ['EMAIL_FROM_NAME', 'string', 'Name that will appear in the "from" field','EMAIL_FROM_NAME=LibreChat'], ]} /> + +## Complete Configuration Examples + +### Example 1: Mailgun Configuration + +```bash +# =================================== +# Email Configuration - Mailgun +# =================================== +# Mailgun is recommended for servers that block SMTP ports + +# Required Mailgun settings +MAILGUN_API_KEY=your-mailgun-api-key +MAILGUN_DOMAIN=mg.yourdomain.com + +# Optional: For EU region +# MAILGUN_HOST=https://api.eu.mailgun.net + +# Common email settings +EMAIL_FROM=noreply@yourdomain.com +EMAIL_FROM_NAME=LibreChat + +# Enable password reset functionality +ALLOW_PASSWORD_RESET=true +``` + +### Example 2: Gmail SMTP Configuration + +```bash +# =================================== +# Email Configuration - Gmail SMTP +# =================================== +# Traditional SMTP configuration + +# Gmail service configuration +EMAIL_SERVICE=gmail +EMAIL_USERNAME=your-email@gmail.com +EMAIL_PASSWORD=your-app-password + +# Common email settings +EMAIL_FROM=your-email@gmail.com +EMAIL_FROM_NAME=LibreChat + +# Enable password reset functionality +ALLOW_PASSWORD_RESET=true +``` + +### Example 3: Custom SMTP Server Configuration + +```bash +# =================================== +# Email Configuration - Custom SMTP +# =================================== +# For custom mail servers + +# SMTP server details +EMAIL_HOST=smtp.example.com +EMAIL_PORT=587 +EMAIL_ENCRYPTION=starttls +EMAIL_USERNAME=username@example.com +EMAIL_PASSWORD=your-password + +# Optional settings +# EMAIL_ENCRYPTION_HOSTNAME= +# EMAIL_ALLOW_SELFSIGNED=false + +# Common email settings +EMAIL_FROM=noreply@example.com +EMAIL_FROM_NAME=LibreChat + +# Enable password reset functionality +ALLOW_PASSWORD_RESET=true +``` + +## Troubleshooting + +### Mailgun Issues + +1. **Authentication Failed**: Ensure your Mailgun API key is correct and has sending permissions +2. **Domain Not Found**: Verify your Mailgun domain is correctly configured in your Mailgun account +3. **EU Region Issues**: If your Mailgun account is in the EU region, make sure to set `MAILGUN_HOST=https://api.eu.mailgun.net` +4. **Fallback to SMTP**: If only one of `MAILGUN_API_KEY` or `MAILGUN_DOMAIN` is set, the system will fall back to SMTP configuration + +### SMTP Issues + +1. **Connection Refused**: Check if your server allows outbound SMTP connections on the specified port +2. **Authentication Failed**: Verify your username and password are correct +3. **Gmail App Password**: For Gmail, you must use an app-specific password, not your regular password +4. **Self-signed Certificates**: If your mail server uses self-signed certificates, set `EMAIL_ALLOW_SELFSIGNED=true` + +### General Issues + +1. **No Emails Sent**: Check the LibreChat logs for error messages +2. **Unsecured Password Reset**: This occurs when neither Mailgun nor SMTP is properly configured +3. **From Address Issues**: Ensure the `EMAIL_FROM` address is valid and authorized to send from your mail service diff --git a/pages/docs/configuration/dotenv.mdx b/pages/docs/configuration/dotenv.mdx index 65fb6babc..b7dda3d25 100644 --- a/pages/docs/configuration/dotenv.mdx +++ b/pages/docs/configuration/dotenv.mdx @@ -1074,13 +1074,32 @@ For more information: **[LDAP/AD Authentication](/docs/configuration/authenticat ### Password Reset -Email is used for account verification and password reset. See: **[Email setup](/docs/configuration/authentication/email)** +Email is used for account verification and password reset. LibreChat supports both Mailgun API and traditional SMTP services. See: **[Email setup](/docs/configuration/authentication/email)** -**Important Note**: All of the service or host, username, and password, and the From address must be set for email to work. +**Important Note**: You must configure either Mailgun (recommended for servers that block SMTP) or SMTP for email to work. + +> **Warning**: Failing to set valid values for either Mailgun or SMTP will result in LibreChat using the unsecured password reset! + +#### Mailgun Configuration (Recommended) + +Mailgun is particularly useful for deployments on servers that block SMTP ports. When both `MAILGUN_API_KEY` and `MAILGUN_DOMAIN` are set, LibreChat will use Mailgun instead of SMTP. + +