sandywp / plugins / wp-email
WP-EMail
Allows people to recommend/send your WordPress blog's post/page to a friend.
Ready in seconds.
v3.0.0 1,000+ installs WP 6.8+ PHP 8.2+

What you get inside
5 screens-
E-Mail -> Settings, covering the link, the form, the checks and delivery
-
The Templates tab, holding all eight templates: the page, the message itself, and what a visitor is told when a send succeeds or fails
-
E-Mail -> Manage E-Mail, the log of what was sent, to whom, and whether it arrived
-
The e-mail link in a post, placed with the shortcode
-
The form behind the link, with its image verification
About this plugin
WP-EMail puts an “Email This Post” link on your posts and pages. A visitor clicking it gets a small form, fills in their name, their friend’s name and address and an optional remark, and the article goes out through wp_mail() — so it uses whatever WordPress itself is set up to send with.
Every message is logged, so you can see what was sent, to whom, from which address and whether it arrived. The page title, the subject line, the HTML body, the plain text body and every message the visitor sees are templates you can edit, each with its own list of variables and a button to put the original back.
Features
- An “Email This Post” link built from an HTML template you edit, with the envelope glyph, the wording and the post type as variables
- A standalone e-mail page or a popup window
- HTML or plain text messages, with the article whole or cut to a word count
- Image verification, and a minimum interval between sends, to keep the form off spammers’ lists
- A sortable, paginated log of every message, with totals and a one-click purge
- A widget and template tags for the most emailed posts and pages
- A block on the WP-Stats page, if you have WP-Stats installed
Donations
I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
Usage
The plugin works as soon as it is activated. All you have to decide is where the e-mail link appears.
On selected posts and pages, type the shortcode into the content:
[email_link]
This works in both block and classic themes, and puts the link exactly where you want it rather than on everything.
On every post and page, call the template tag from your theme instead. In a classic theme, open wp-content/themes/<YOUR THEME NAME>/index.php — or single.php, page.php, and so on — find:
<?php while ( have_posts() ) : the_post(); ?>
and add this inside the loop, where you want the link to show:
<?php if ( function_exists( 'email_link' ) ) { email_link(); } ?>
Use one or the other, not both, or the link appears twice.
If the link is there but clicking it gives a 404, re-save your permalinks under WP-Admin -> Settings -> Permalinks. The plugin registers its /email/ endpoint on activation, but a site with unusual rewrite rules can need the nudge.
Everything else is configured under WP-Admin -> E-Mail -> Settings, which has two tabs: Settings for the link, the form and delivery, and Templates for the eight message templates. The log of what has been sent is under WP-Admin -> E-Mail -> Manage E-Mail.
Filters
Use wp_email_capability to hand a screen to a capability other than the default. The logs screen is gated on manage_email and the settings screen on manage_options:
add_filter( 'wp_email_capability', function ( $capability, $context ) {
return 'logs' === $context ? 'edit_posts' : $capability;
}, 10, 2 );
Use wp_email_form_field_values to pre-fill the form. The plugin uses it itself to fill in a logged-in visitor’s name and address:
add_filter( 'wp_email_form_field_values', function ( $values ) {
$values['yourremarks'] = 'Thought you would like this.';
return $values;
} );
The other three are wp_email_ipaddress (the address a send is attributed to), wp_email_template_redirect (whether the plugin takes over the request for its own endpoints) and wp_email_trust_proxy (whether the usual forwarding headers may be trusted).
Questions
- How does the plugin send mail?
Through
wp_mail(), so it uses whatever WordPress itself is configured to use. The plugin dropped its own SMTP settings in 2.68.0; if you need SMTP, install an SMTP plugin and WP-EMail will follow it.- How can I customize my E-Mail link?
Edit the E-Mail Link Template under
WP-Admin -> E-Mail -> Settings. It is the whole of the link’s markup, and it ships as:<a href="%EMAIL_URL%" data-wp-email-popup="%EMAIL_POPUP%" title="Email This %POST_TYPE%" rel="nofollow">%EMAIL_ICON% Email This %POST_TYPE%</a>Four variables are available:
%EMAIL_URL%— the e-mail page or popup for this post%EMAIL_POPUP%—1when the E-Mail Link Type is the popup,0otherwise; it belongs inside thedata-wp-email-popupattribute%EMAIL_ICON%— the envelope glyph, drawn inline%POST_TYPE%— the singular name of what is being viewed:Post,Page, or a custom post type’s own label
Leave one out to drop it. A template without
%EMAIL_ICON%is a text link; one holding nothing but%EMAIL_ICON%is an icon, and the anchor’stitleis then what a screen reader announces. Restore Default Template puts the shipped markup back.An unrecognised variable is left in the markup as written rather than blanked, so a typo shows up on the page instead of silently emptying the link.
Setting the third parameter of
email_link()tofalsereturns the link instead of echoing it:$email_link = function_exists( 'email_link' ) ? email_link( '', '', false ) : ''; echo $email_link;The first two parameters are still accepted so that a theme written before 3.0.0 does not fatal, but they no longer do anything.
- How can I show my E-Mail stats?
Two ways. Add the widget named “Email” under
WP-Admin -> Appearance -> Widgets, or call one of the template tags from your theme.- How can I display the Most E-Mailed Posts?
Insert this into your theme:
if ( function_exists( 'get_mostemailed' ) ) { get_mostemailed( 'both', 10 ); }The first parameter is what to list —
post,pageorboth— and the second is how many.- How can I display the totals?
get_emails() for everything sent,
get_emails_success()for what went out successfully,get_emails_failed()for what did not, andget_email_count()for one post:if ( function_exists( 'get_emails' ) ) { get_emails(); }- Visitors are told to wait before sending, or every log row shows the same IP
Your site is behind a reverse proxy or CDN — Cloudflare, a load balancer, nginx in front of Apache — so the address PHP sees is the proxy’s, not the visitor’s. Because the interval between e-mails is keyed on that address, every visitor shares one interval and each of them is told to wait for somebody else’s send.
The real address is in a forwarded header, but WP-EMail ignores those by default: any client can send one with any value, so trusting them blindly lets a visitor forge an address and bypass the interval entirely. Opt in only if a proxy you control actually sets the header.
If you know which header it is, name it under
WP-Admin -> E-Mail -> Settingsin theHeader That Contains The IPfield — for exampleHTTP_CF_CONNECTING_IPfor Cloudflare. That is the narrowest option, and the one to prefer.To trust the usual set instead (
X-Forwarded-For,CF-Connecting-IPand friends), add this towp-config.phpabove the/* That's all, stop editing! */line:define( 'WP_EMAIL_TRUST_PROXY', true );If you need to decide per request — say, only trust the header when the request arrives from your load balancer — use the filter instead:
add_filter( 'wp_email_trust_proxy', function () { return isset( $_SERVER['REMOTE_ADDR'] ) && '10.0.0.1' === $_SERVER['REMOTE_ADDR']; } );With none of the three set, the plugin uses
REMOTE_ADDR— correct on a plain host, and the proxy’s address behind one.- How do I hide remarks when viewing E-Mail logs in WP-Admin?
Add this to your
wp-config.php:define( 'WP_EMAIL_SHOW_REMARKS', false );The constant was called
EMAIL_SHOW_REMARKSbefore 3.0.0. The plugin only defines it if you have not, so your setting survives upgrades.- How can I keep some post text from being sent in the E-Mail?
Wrap it:
[donotemail]Text within this tag will not be displayed when emailed[/donotemail]The text inside will not appear in the message, but it will still show on the post or page as normal. Note that if you also run WP-Print, text inside
[donotemail]will not be printed either.
sandywp / also on the shelf
Try another plugin
4.8 · 100K+ installs
Enable and disable email notifications that WordPress sends to the admin and user. Works perfectly with many other plugins!
4.7 · 10K+ installs
Postie allows you to create posts via email, including many advanced features not found in WordPress's default Post by Email…
Cryptex | E-Mail Address Protection
4.0 · 900+ installs
Cryptex transforms plain-text E-Mail-Addresses into Images - automatically - No scrapers. No harvesters. No spambots. That's our…
Spin up a real WordPress site in seconds.
Test plugins, build a demo, hand a client a link — then squash it and start again. No local setup, no Docker.