Email & SMTP
Configure email sending with SMTP in EZ-Console.
Overview
EZ-Console supports email sending via SMTP for notifications, password resets, MFA codes, and other system emails. SMTP settings can be configured through the admin console.
Accessing SMTP Settings
Navigate to: System Settings → Email & SMTP
SMTP Configuration
Basic SMTP Settings
smtp:
host: "smtp.example.com"
port: 587
username: "[email protected]"
password: "your-password"
from_email: "[email protected]"
from_name: "EZ-Console"
use_tls: true
Configuration Options
- host: SMTP server hostname (required)
- port: SMTP server port (default:
587for TLS,465for SSL,25for plain) - username: SMTP username (required)
- password: SMTP password (required)
- from_email: Sender email address (required)
- from_name: Sender display name (optional)
- use_tls: Use TLS encryption (default:
true) - use_ssl: Use SSL encryption (default:
false)
Common SMTP Providers
Gmail
smtp:
host: "smtp.gmail.com"
port: 587
username: "[email protected]"
password: "your-app-password" # Use App Password, not regular password
from_email: "[email protected]"
from_name: "EZ-Console"
use_tls: true
Note: For Gmail, you need to:
- Enable 2-Step Verification
- Generate an App Password
- Use the App Password instead of your regular password
Outlook/Office 365
smtp:
host: "smtp.office365.com"
port: 587
username: "[email protected]"
password: "your-password"
from_email: "[email protected]"
from_name: "EZ-Console"
use_tls: true
SendGrid
smtp:
host: "smtp.sendgrid.net"
port: 587
username: "apikey"
password: "your-sendgrid-api-key"
from_email: "[email protected]"
from_name: "EZ-Console"
use_tls: true
Amazon SES
smtp:
host: "email-smtp.us-east-1.amazonaws.com" # Use your region
port: 587
username: "your-ses-smtp-username"
password: "your-ses-smtp-password"
from_email: "[email protected]"
from_name: "EZ-Console"
use_tls: true
Custom SMTP Server
smtp:
host: "mail.example.com"
port: 587
username: "[email protected]"
password: "secure-password"
from_email: "[email protected]"
from_name: "EZ-Console"
use_tls: true
Configuration via UI
- Navigate to System Settings → Email & SMTP
- Enter SMTP server details
- Click Test Connection to verify
- Click Save to apply settings
Configuration via API
Get SMTP Settings
GET /api/system/settings/smtp
Response:
{
"code": "0",
"data": {
"host": "smtp.example.com",
"port": 587,
"username": "[email protected]",
"from_email": "[email protected]",
"from_name": "EZ-Console",
"use_tls": true
}
}
Update SMTP Settings
PUT /api/system/settings/smtp
Request Body:
{
"host": "smtp.example.com",
"port": 587,
"username": "[email protected]",
"password": "your-password",
"from_email": "[email protected]",
"from_name": "EZ-Console",
"use_tls": true
}
Testing SMTP Connection
Via UI
- Go to System Settings → Email & SMTP
- Enter SMTP settings
- Click Test Connection
- Check test email in your inbox
Via API
POST /api/system/settings/smtp/test
Request Body:
{
"to": "[email protected]",
"subject": "Test Email",
"body": "This is a test email from EZ-Console"
}
Email Templates
EZ-Console uses email templates for system emails:
- Password Reset: Sent when user requests password reset
- MFA Code: Sent for email-based MFA
- Welcome Email: Sent to new users (if enabled)
- Account Locked: Sent when account is locked
Using Email in Code
Send Email via Service
import (
"context"
"github.com/sven-victor/ez-console/server"
)
func SendNotification(ctx context.Context, svc server.Service, to []string, subject, body string) error {
smtpSettings, err := svc.GetSMTPSettings(ctx)
if err != nil {
return err
}
return svc.SendEmail(ctx, smtpSettings, to, subject, body)
}
Troubleshooting
Connection Failed
Symptom: Cannot connect to SMTP server
Solutions:
- Verify host and port are correct
- Check firewall rules
- Verify credentials
- Try different ports (587, 465, 25)
Authentication Failed
Symptom: Authentication error
Solutions:
- Verify username and password
- For Gmail, use App Password
- Check if account requires 2FA
- Verify account is not locked
Emails Not Received
Symptom: Emails sent but not received
Solutions:
- Check spam folder
- Verify sender email is not blocked
- Check SMTP server logs
- Verify recipient email is valid
TLS/SSL Errors
Symptom: TLS handshake failed
Solutions:
- Verify
use_tlsoruse_sslsettings - Check port matches encryption type
- Verify certificate is valid
- Try different port
Security Best Practices
1. Use App Passwords
For services like Gmail, use App Passwords instead of regular passwords.
2. Encrypt Connections
Always use TLS or SSL for SMTP connections.
3. Secure Credentials
Store SMTP passwords securely, never in code or config files.
4. Limit Access
Restrict SMTP settings to admin users only.
Related Topics
- System Settings - System configuration
- Configuration Guide - General configuration
Need help? Ask in GitHub Discussions.