WordPress: Add an “Email this page” link to your website or blog posts
Here is the simple line of code that I use to add an “Email this page” link to a WordPress website or blog. Simply add this code snippet to the template file where you want the link to show up – the header.php file, the page template, the single post template, etc.
<a href="mailto:?subject=<?php urlencode(the_title()) ?>&body=<?php urlencode(the_permalink()) ?>">Email this link to a friend</a>
When the “Email this page” link is clicked, a new email is opened which has the page title of the page you are sending as the subject line and has a link to the page you are sending in the body of the email.
You could use this line of code if you want the subject line to be something specific, rather than the page title:
<a href="mailto:?subject=Check out this website&body=<?php urlencode(the_permalink()) ?>">Email this link to a friend </a>
Simply change the words “Check out this website” in the code above to whatever you want the subject line of the emails to be.
As always, let me know if you have any questions, I’d be happy to help!