WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sorry but I get lost on Wordpress's codex. I am trying to add a mail this page sharing link and want to include some info from the page. In pseudo code is this possible?

<a href="mailto:?subject=".CURRENT_BLOG_NAME." ".CURRENT_PAGE_TITLE."&amp;body="intro%20text%20".WP_PLUGIN_URL.$_SERVER['REQUEST_URI'].">Mail to a friend</a>


WP_PLUGIN_URL.$_SERVER['REQUEST_URI'] does get me the path to the current page.

share|improve this question
up vote 1 down vote accepted
$link = 'mailto:?subject='. get_bloginfo() .' '. the_title_attribute(array('echo'=>0));
$link .= '&amp;body=some text '. get_permalink();
<a href="<?php echo $link ?>">mail to a friend</a>
share|improve this answer
I think this is the long way but it works also 'http%3A%2F%2F'.$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI'] – JohnnyBizzle Aug 16 '11 at 10:49

There's the wp_mail($to, $subject, $message, $headers, $attachments); function for such things.

Furthermore there's a function called get_permalink();. And another one called get_the_title();.

You can combine them in a function:

function wpse25552_mail_permalink()
    global $post;
    $post_id = $post->ID;

    $title = get_the_title( $post_id );
    $subject = sprintf( __('I want to share %1$s with you', YOUR_TEXTDOMAIN ), $title );

    $permalink = get_permalink( $post_id );
    $message = sprintf( __('Yo! Look what I've found here: %1$s', YOUR_TEXTDOMAIN), $permalink );

    // ... stuff for $to, $subject, etc.

    wp_mail($to, $subject, $message, $headers, $attachments);

Note, that you have to replace YOUR_TEXTDOMAIN with your themes textdomain string. Else you can leave it out (don't forget to delete the comma too).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.