Page 1 of 1

Filling in the email FROM & Body on click

Posted: Sat Aug 07, 2004 2:36 pm
by AbrasiveRock
Ok, I have been searching everywhere (including the search feature here) to figure out this very simple task.

When people click a link, I want it to open up their email client with their email address in the From spot. I want the message body to be the url that the link was clicked.

EDIT: The part I can't figure out is how to make it detect the url the link was clicked from.

In the end it should be something that can be placed in a sever side include. This is why I am trying to get it to detect what url it was clicked from. I found the script once, but can't remember where.

Posted: Sat Aug 07, 2004 2:42 pm
by feyd

Code: Select all

<a href="mailto:whatever@yoursite.com?subject=urlencoded_subject&message=urlencoded_message">click me!</a>
I think... might be body=blah

Posted: Sat Aug 07, 2004 2:47 pm
by AbrasiveRock
Ok, what I have so far is...

Code: Select all

<A HREF="mailto:?subject=Check this website out!&body=This_Is_The_Part_That_I_Want_To_Detect_The_URL_The_Link_Was_Clicked_From">Send This Page To A Friend</A><P>
So I have everything except making the body list the URL is was clicked from.

Posted: Sat Aug 07, 2004 2:58 pm
by feyd

Code: Select all

<?php

echo '<a href="mailto:?subject=' . urlencode($subject) . '&body=' . urlencode($_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . $_SERVER['REQUEST_STRING']) . '">Send this page to a friend</a>';

?>
note: most sites have an in-site form that the user fills out to email it, so the site can add any extra details and markings with better ease. Generally with a custom message the sender can add, if they'd like.