Email customization
Overview
Password reset emails can be customized through plugin settings for basic changes or WordPress filters for advanced HTML templates. The plugin sends HTML emails with template variables that are replaced with actual user data.
Basic customization (Settings)
The easiest way to customize emails is through General settings in the WordPress admin.
Email subject
Setting: Email Subject
Default: "Account Password Reset"
Template variables: {username}, {email}
Example:
Password Reset Request for {username}
Email body
Setting: Email Message
Default: Standard WordPress reset email text
Template variables: {username}, {reset_link}, {email}
Example:
<p>Hi {username},</p>
<p>Someone requested a password reset for your account at our site.</p>
<p>If this was you, click the link below to reset your password:</p>
<p>{reset_link}</p>
<p>If you didn't request this, you can safely ignore this email.</p>
<p>Thanks,<br>
The Team</p>
Sender information
From Name: Name displayed as email sender
From Email: Email address used as sender
Example:
- From Name: "My Site Support"
- From Email: "[email protected]"
Reset link text
Setting: Reset Link Text
Purpose: Custom text for the reset link instead of showing the full URL
Example:
Click here to reset your password
This creates: <a href="{reset_link}">Click here to reset your password</a>
Template variables
Three variables are available in email subject and body:
{username}
Replaced with: User's WordPress login name
Use in: Subject and body
Example:
Hi {username}, we received a password reset request for your account.
{reset_link}
Replaced with: Full password reset URL with key and user ID
Use in: Body only
The link includes:
- Base URL (reset password page)
somresetpass=trueparameterkeyparameter (reset key)uidparameter (user ID)
Example URL:
https://example.com/reset-password/?somresetpass=true&key=abc123&uid=45
{email}
Replaced with: User's email address
Use in: Subject and body
Example:
This email was sent to {email}. If this is not your email address, please ignore this message.
Advanced customization (Filters)
For complete control over email content, use WordPress filters in your theme's functions.php.
Email subject filter
Filter: somfrp_retrieve_password_title
Parameters: $title, $user_login, $user_data
Example:
add_filter( 'somfrp_retrieve_password_title', 'custom_reset_email_subject', 10, 3 );
function custom_reset_email_subject( $title, $user_login, $user_data ) {
$site_name = get_bloginfo( 'name' );
return sprintf( '[%s] Password Reset for %s', $site_name, $user_login );
}
Email body filter
Filter: somfrp_retrieve_password_message
Parameters: $message, $key, $user_login, $user_data
Example:
add_filter( 'somfrp_retrieve_password_message', 'custom_reset_email_body', 10, 4 );
function custom_reset_email_body( $message, $key, $user_login, $user_data ) {
$reset_url = som_get_lost_password_url() . '?somresetpass=true&key=' . $key . '&uid=' . $user_data->ID;
$message = '<html><body>';
$message .= '<div style="max-width: 600px; margin: 0 auto; font-family: Arial, sans-serif;">';
$message .= '<h2 style="color: #333;">Password Reset Request</h2>';
$message .= '<p>Hello ' . esc_html( $user_login ) . ',</p>';
$message .= '<p>We received a request to reset your password. Click the button below to create a new password:</p>';
$message .= '<p style="text-align: center;">';
$message .= '<a href="' . esc_url( $reset_url ) . '" style="display: inline-block; padding: 12px 24px; background: #0073aa; color: #fff; text-decoration: none; border-radius: 4px;">Reset Password</a>';
$message .= '</p>';
$message .= '<p style="color: #666; font-size: 14px;">If you didn\'t request this, you can safely ignore this email.</p>';
$message .= '<p style="color: #666; font-size: 14px;">This link will expire in 24 hours.</p>';
$message .= '</div>';
$message .= '</body></html>';
return $message;
}
Email testing
Test your custom emails:
Method 1: Use a test account
- Create a test user account
- Request password reset for that account
- Check the email received
- Verify all links work correctly
Method 2: Use email testing plugin
Install an email testing plugin like "WP Mail Logging" to capture and preview emails without sending them.
Method 3: Use email testing service
Use services like Mailtrap or MailHog to capture test emails in a development environment.
Troubleshooting
Emails not sending
See Email troubleshooting guide for detailed solutions.
HTML not rendering
Problem: Email displays HTML code instead of formatted content.
Solution: Ensure email content type is set to HTML. The plugin handles this automatically, but some email plugins may interfere.
Template variables not replaced
Problem: Email shows {username} instead of actual username.
Solution: Verify you're using the correct variable names: {username}, {reset_link}, {email}. Variables are case-sensitive.
Custom filter not working
Problem: Custom email filter doesn't apply.
Solution:
- Verify filter name is correct:
somfrp_retrieve_password_message - Check filter priority (default is 10)
- Ensure code is in active theme's
functions.php - Clear all caches
Best practices
Keep it simple
Don't overcomplicate email templates. Simple, clear emails have better deliverability.
Test thoroughly
Test emails on multiple email clients:
- Gmail
- Outlook
- Apple Mail
- Mobile email apps
Use inline CSS
Email clients have limited CSS support. Use inline styles instead of external stylesheets.
What's next
- Translations - Translate email content
- General settings - Configure email settings
- Email troubleshooting - Fix email delivery issues