Skip to content

Commit 103ed0f

Browse files
authored
πŸ“§ docs: Mailgun API Email Configuration (#317)
* πŸ“§ docs: Mailgun API email configuration * πŸ“ docs: Update agents configuration note to include custom endpoint option
1 parent 0d937e5 commit 103ed0f

File tree

4 files changed

+182
-14
lines changed

4 files changed

+182
-14
lines changed

β€Žpages/docs/configuration/authentication/email.mdx

Lines changed: 149 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Email setup
3-
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.
3+
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.
44
---
55

66
# Email verification and Password Reset
@@ -9,6 +9,35 @@ For a quick overview, refer to the user guide provided here: [Password Reset](/d
99

1010
## General setup
1111

12+
LibreChat supports multiple email providers:
13+
- **Mailgun API** - Recommended for servers that block SMTP ports
14+
- **SMTP Services** - Traditional email sending via Gmail, Outlook, or custom mail servers
15+
16+
### Common Configuration
17+
18+
These variables are used by both Mailgun and SMTP:
19+
20+
<OptionTable
21+
options={[
22+
['EMAIL_FROM', 'string', 'From email address. Required.','EMAIL_FROM=noreply@librechat.ai'],
23+
['EMAIL_FROM_NAME', 'string', 'From name (defaults to APP_TITLE if not set).','EMAIL_FROM_NAME=LibreChat'],
24+
]}
25+
/>
26+
27+
### Mailgun Configuration (Recommended)
28+
29+
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.
30+
31+
<OptionTable
32+
options={[
33+
['MAILGUN_API_KEY', 'string', 'Your Mailgun API key (required for Mailgun).','MAILGUN_API_KEY='],
34+
['MAILGUN_DOMAIN', 'string', 'Your Mailgun domain, e.g., mg.yourdomain.com (required for Mailgun).','MAILGUN_DOMAIN='],
35+
['MAILGUN_HOST', 'string', 'Custom Mailgun API host (optional). Use https://api.eu.mailgun.net for EU region.','MAILGUN_HOST=https://api.mailgun.net'],
36+
]}
37+
/>
38+
39+
### SMTP Configuration
40+
1241
**Basic Configuration**
1342

1443
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
1948
['EMAIL_SERVICE', 'string', 'Email service (e.g., Gmail, Outlook).','EMAIL_SERVICE='],
2049
['EMAIL_USERNAME', 'string', 'Username for authentication.','EMAIL_USERNAME='],
2150
['EMAIL_PASSWORD', 'string', 'Password for authentication.','EMAIL_PASSWORD='],
22-
['EMAIL_FROM_NAME', 'string', 'From name.','EMAIL_FROM_NAME='],
23-
['EMAIL_FROM', 'string', 'From email address. Required.','EMAIL_FROM=noreply@librechat.ai'],
2451
]}
2552
/>
2653

@@ -39,7 +66,30 @@ If you want to use a generic SMTP service or need advanced configuration for one
3966
/>
4067

4168
<Callout type="warning" title="Warning">
42-
**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!**
69+
**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!**
70+
</Callout>
71+
72+
## Setup with Mailgun
73+
74+
To set up Mailgun, follow these steps:
75+
76+
1. Sign up for a Mailgun account at [mailgun.com](https://www.mailgun.com/)
77+
2. Add and verify your domain in the Mailgun dashboard
78+
3. Navigate to the API Keys section and copy your Private API key
79+
4. In the `.env` file, modify the variables as follows:
80+
81+
<OptionTable
82+
options={[
83+
['MAILGUN_API_KEY', 'string', 'Your Mailgun private API key', 'MAILGUN_API_KEY=your-mailgun-api-key'],
84+
['MAILGUN_DOMAIN', 'string', 'Your verified Mailgun domain', 'MAILGUN_DOMAIN=mg.yourdomain.com'],
85+
['EMAIL_FROM', 'string', 'Sender email address', 'EMAIL_FROM=noreply@yourdomain.com'],
86+
['EMAIL_FROM_NAME', 'string', 'Sender name', 'EMAIL_FROM_NAME=LibreChat'],
87+
['MAILGUN_HOST', 'string', '(Optional) For EU region', 'MAILGUN_HOST=https://api.eu.mailgun.net'],
88+
]}
89+
/>
90+
91+
<Callout type="info" title="Note">
92+
If your Mailgun account is in the EU region, make sure to set `MAILGUN_HOST=https://api.eu.mailgun.net`
4393
</Callout>
4494

4595
## Setup with Gmail
@@ -80,3 +130,98 @@ To set up a custom mail server, follow these steps:
80130
['EMAIL_FROM_NAME', 'string', 'Name that will appear in the "from" field','EMAIL_FROM_NAME=LibreChat'],
81131
]}
82132
/>
133+
134+
## Complete Configuration Examples
135+
136+
### Example 1: Mailgun Configuration
137+
138+
```bash
139+
# ===================================
140+
# Email Configuration - Mailgun
141+
# ===================================
142+
# Mailgun is recommended for servers that block SMTP ports
143+
144+
# Required Mailgun settings
145+
MAILGUN_API_KEY=your-mailgun-api-key
146+
MAILGUN_DOMAIN=mg.yourdomain.com
147+
148+
# Optional: For EU region
149+
# MAILGUN_HOST=https://api.eu.mailgun.net
150+
151+
# Common email settings
152+
EMAIL_FROM=noreply@yourdomain.com
153+
EMAIL_FROM_NAME=LibreChat
154+
155+
# Enable password reset functionality
156+
ALLOW_PASSWORD_RESET=true
157+
```
158+
159+
### Example 2: Gmail SMTP Configuration
160+
161+
```bash
162+
# ===================================
163+
# Email Configuration - Gmail SMTP
164+
# ===================================
165+
# Traditional SMTP configuration
166+
167+
# Gmail service configuration
168+
EMAIL_SERVICE=gmail
169+
EMAIL_USERNAME=your-email@gmail.com
170+
EMAIL_PASSWORD=your-app-password
171+
172+
# Common email settings
173+
EMAIL_FROM=your-email@gmail.com
174+
EMAIL_FROM_NAME=LibreChat
175+
176+
# Enable password reset functionality
177+
ALLOW_PASSWORD_RESET=true
178+
```
179+
180+
### Example 3: Custom SMTP Server Configuration
181+
182+
```bash
183+
# ===================================
184+
# Email Configuration - Custom SMTP
185+
# ===================================
186+
# For custom mail servers
187+
188+
# SMTP server details
189+
EMAIL_HOST=smtp.example.com
190+
EMAIL_PORT=587
191+
EMAIL_ENCRYPTION=starttls
192+
EMAIL_USERNAME=username@example.com
193+
EMAIL_PASSWORD=your-password
194+
195+
# Optional settings
196+
# EMAIL_ENCRYPTION_HOSTNAME=
197+
# EMAIL_ALLOW_SELFSIGNED=false
198+
199+
# Common email settings
200+
EMAIL_FROM=noreply@example.com
201+
EMAIL_FROM_NAME=LibreChat
202+
203+
# Enable password reset functionality
204+
ALLOW_PASSWORD_RESET=true
205+
```
206+
207+
## Troubleshooting
208+
209+
### Mailgun Issues
210+
211+
1. **Authentication Failed**: Ensure your Mailgun API key is correct and has sending permissions
212+
2. **Domain Not Found**: Verify your Mailgun domain is correctly configured in your Mailgun account
213+
3. **EU Region Issues**: If your Mailgun account is in the EU region, make sure to set `MAILGUN_HOST=https://api.eu.mailgun.net`
214+
4. **Fallback to SMTP**: If only one of `MAILGUN_API_KEY` or `MAILGUN_DOMAIN` is set, the system will fall back to SMTP configuration
215+
216+
### SMTP Issues
217+
218+
1. **Connection Refused**: Check if your server allows outbound SMTP connections on the specified port
219+
2. **Authentication Failed**: Verify your username and password are correct
220+
3. **Gmail App Password**: For Gmail, you must use an app-specific password, not your regular password
221+
4. **Self-signed Certificates**: If your mail server uses self-signed certificates, set `EMAIL_ALLOW_SELFSIGNED=true`
222+
223+
### General Issues
224+
225+
1. **No Emails Sent**: Check the LibreChat logs for error messages
226+
2. **Unsecured Password Reset**: This occurs when neither Mailgun nor SMTP is properly configured
227+
3. **From Address Issues**: Ensure the `EMAIL_FROM` address is valid and authorized to send from your mail service

β€Žpages/docs/configuration/dotenv.mdx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,13 +1104,32 @@ For more information: **[LDAP/AD Authentication](/docs/configuration/authenticat
11041104

11051105
### Password Reset
11061106

1107-
Email is used for account verification and password reset. See: **[Email setup](/docs/configuration/authentication/email)**
1107+
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)**
11081108

1109-
**Important Note**: All of the service or host, username, and password, and the From address must be set for email to work.
1109+
**Important Note**: You must configure either Mailgun (recommended for servers that block SMTP) or SMTP for email to work.
1110+
1111+
> **Warning**: Failing to set valid values for either Mailgun or SMTP will result in LibreChat using the unsecured password reset!
1112+
1113+
#### Mailgun Configuration (Recommended)
1114+
1115+
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.
1116+
1117+
<OptionTable
1118+
options={[
1119+
['MAILGUN_API_KEY', 'string', 'Your Mailgun API key (required for Mailgun).','MAILGUN_API_KEY='],
1120+
['MAILGUN_DOMAIN', 'string', 'Your Mailgun domain (required for Mailgun).','MAILGUN_DOMAIN=mg.yourdomain.com'],
1121+
['MAILGUN_HOST', 'string', 'Custom Mailgun API host (optional). Use https://api.eu.mailgun.net for EU region.','MAILGUN_HOST=https://api.mailgun.net'],
1122+
['EMAIL_FROM', 'string', 'From email address. Required.','EMAIL_FROM=noreply@librechat.ai'],
1123+
['EMAIL_FROM_NAME', 'string', 'From name (defaults to APP_TITLE if not set).','EMAIL_FROM_NAME='],
1124+
]}
1125+
/>
1126+
1127+
#### SMTP Configuration
1128+
1129+
If Mailgun is not configured, LibreChat will fall back to SMTP settings.
11101130

11111131
> **Warning**: If using `EMAIL_SERVICE`, **do NOT** set the extended connection parameters:
11121132
> HOST, PORT, ENCRYPTION, ENCRYPTION_HOSTNAME, ALLOW_SELFSIGNED.
1113-
> Failing to set valid values here will result in LibreChat using the unsecured password reset!
11141133
11151134
See: **[nodemailer well-known-services](https://community.nodemailer.com/2-0-0-beta/setup-smtp/well-known-services/)**
11161135

β€Žpages/docs/configuration/librechat_yaml/object_structure/agents.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ disableBuilder: false
7474

7575
**Default:** `[]` (empty list, all providers allowed)
7676

77-
**Note:** Must be one of the following:
77+
**Note:** Must be one of the following, or a custom endpoint name as defined in your [configuration](/docs/configuration/librechat_yaml/object_structure/custom_endpoint#name):
7878
- `openAI, azureOpenAI, google, anthropic, assistants, azureAssistants, bedrock`
7979

8080
**Example:**

β€Žpages/docs/features/password_reset.mdx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,21 @@ description: This feature enables email-based password reset functionality for y
2323

2424
## Overview
2525

26-
This feature enables email-based password reset functionality for your LibreChat server. You can configure it to work with various email services, including Gmail and custom mail servers.
26+
This feature enables email-based password reset functionality for your LibreChat server. You can configure it to work with various email services, including Mailgun API, Gmail, and custom mail servers.
2727

2828
## Key Features
2929

30-
- Supports multiple email services, including Gmail and custom mail servers
30+
- Supports multiple email services:
31+
- **Mailgun API** - Recommended for servers that block SMTP ports
32+
- **Gmail** and other predefined SMTP services
33+
- **Custom mail servers** with advanced SMTP configuration
3134
- Allows for basic and advanced configuration options
32-
- Enables email-based password reset functionality for your LibreChat server
35+
- Enables secure email-based password reset functionality for your LibreChat server
3336

3437
## Setup Options
3538

36-
- Basic Configuration: Use predefined services with minimal configuration
37-
- Advanced Configuration: Configure generic SMTP services or customize settings for predefined providers
39+
- **Mailgun Configuration**: Use Mailgun's API for reliable email delivery, especially useful when SMTP ports are blocked
40+
- **Basic SMTP Configuration**: Use predefined services like Gmail with minimal configuration
41+
- **Advanced SMTP Configuration**: Configure generic SMTP services or customize settings for any mail provider
3842

39-
**For further details, refer to the configuration guides provided here: [Password Reset](/docs/configuration/authentication/email)**
43+
**For detailed setup instructions, refer to the configuration guide: [Email Setup](/docs/configuration/authentication/email)**

0 commit comments

Comments
Β (0)