Skip to content

Instantly share code, notes, and snippets.

@justinwhall
Created March 8, 2012 00:56
Show Gist options
  • Save justinwhall/1997673 to your computer and use it in GitHub Desktop.
Save justinwhall/1997673 to your computer and use it in GitHub Desktop.
PHP: Function e-mail share
//email share function
function direct_email($text="Send by email"){
global $post;
$title = htmlspecialchars($post->post_title);
$excerpt = htmlspecialchars($post->the_excerpt);
$subject = 'Article by '.htmlspecialchars(get_bloginfo('name')).': '.$title . $excerpt;
$body = 'Check out this article from Justin W Hall: '.$title. "\n" . "\n" .get_permalink($post->ID);
$link = '<a rel="nofollow" href="mailto:?subject='.rawurlencode($subject).'&amp;body='.rawurlencode($body).'" title="'.$text.' : '.$title.'">'.$text.'</a>';
return $link;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment