Email Redirect
A WordPress plugin that redirects users to custom URLs based on their email domain. Features widget support, shortcodes, an admin settings page for domain-to-URL mappings, and intelligent subdomain matching with fallback to main domains.
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/latinvm/wordpress-email-redirect/archive/refs/heads/main.zipEmail Redirect WordPress Plugin
Description
This WordPress plugin redirects users to URLs based on their email domain. Users enter their email address in a form, and the plugin automatically opens the appropriate URL based on domain mappings you configure.
Features
- Widget-based email input form
- Shortcode support for inline placement in posts and pages
- Admin settings page for easy domain-to-URL configuration
- Subdomain matching with priority over main domain matches
- Popup window with fallback link if popups are blocked
- AJAX-based submission for smooth user experience
- Input validation for email addresses
Installation
-
Create a folder named
email-redirectin your WordPresswp-content/plugins/directory -
Copy all plugin files into this folder:
- email-redirect.php (main plugin file)
- widget.php
- script.js
- style.css
- admin-script.js
- admin-style.css
- languages/ (folder with translation files)
-
Activate the plugin through the WordPress admin panel (Plugins > Installed Plugins)
Compiling Translations (optional)
If you modify the .po translation files, regenerate the compiled .mo files:
cd wp-content/plugins/email-redirect/languages
msgfmt -o email-redirect-nl_NL.mo email-redirect-nl_NL.po
Configuration
Setting up Domain Mappings
- Go to Settings > Email Redirect in your WordPress admin
- Add domain-to-URL mappings:
- Enter the domain (without protocol), e.g.,
company.comormail.company.com - Enter the complete redirect URL, e.g.,
https://example.com/page
- Enter the domain (without protocol), e.g.,
- Click "Add Mapping" to add more rows
- Click "Remove" to delete unwanted mappings
- Click "Save Changes" when done
Domain Matching Priority
The plugin uses the following matching logic:
- First attempts exact domain match (including subdomain if present)
- If no exact match, extracts and checks the main domain + TLD
- Subdomain configurations always take precedence
Example:
- If you configure both
mail.company.comandcompany.com - Email
user@mail.company.comwill matchmail.company.comfirst - Email
user@company.comwill matchcompany.com - Email
user@support.company.comwill matchcompany.com(main domain fallback)
Usage
Adding the Widget
- Go to Appearance > Widgets in WordPress admin
- Find "Email Redirect Form" widget
- Drag it to your desired widget area (sidebar, footer, etc.)
- Optionally set a custom title
- Save the widget
Using the Shortcode
You can also embed the form directly in any post, page, or shortcode-enabled area:
[email_redirect_form]
With a custom title:
[email_redirect_form title="Enter Your Email"]
User Experience
When a user submits their email:
- The plugin validates the email format
- Extracts the domain from the email
- Finds the matching redirect URL from your configuration
- Opens the URL in a new browser window
- Shows a confirmation message with a clickable link
- If the domain is not found, shows an error message
File Structure
email-redirect/
├── email-redirect.php # Main plugin file
├── widget.php # Widget class
├── script.js # Frontend JavaScript
├── style.css # Widget styling
├── admin-script.js # Admin JavaScript
├── admin-style.css # Admin styling
└── languages/ # Translation files
├── email-redirect.pot # Translation template
├── email-redirect-nl_NL.po # Dutch translation source
└── email-redirect-nl_NL.mo # Dutch translation (compiled)
Translations
The plugin includes Dutch (nl_NL) translations and is fully translatable.
Required Tools
To compile translations, you need gettext which provides the msgfmt command:
Ubuntu/Debian:
sudo apt install gettext
macOS (Homebrew):
brew install gettext
Windows: Download from GNU gettext or use Poedit.
Adding a New Translation
-
Copy the template file to create a new translation:
cp email-redirect.pot email-redirect-de_DE.po -
Edit the
.pofile with a text editor or Poedit, translating eachmsgstrentry -
Compile the
.pofile to.mo:msgfmt -o email-redirect-de_DE.mo email-redirect-de_DE.po
Updating Existing Translations
-
Edit the
.pofile (e.g.,email-redirect-nl_NL.po) -
Recompile to
.mo:msgfmt -o email-redirect-nl_NL.mo email-redirect-nl_NL.po
Using Poedit (GUI Alternative)
Poedit provides a graphical interface for editing translations and automatically generates the .mo file when you save.
Technical Details
- Uses WordPress AJAX for form processing
- Nonce verification for security
- Sanitization and validation of all inputs
- Responsive form design
- Compatible with standard WordPress themes
Requirements
- WordPress 5.0 or higher
- PHP 7.0 or higher
- jQuery (included with WordPress)
Support
For issues or questions, contact your plugin administrator.
License
This plugin is licensed under the GPL-2.0-or-later license.