开发者

How can I add an "Email This" button that will NOT use mailto:

I want a button that does not just use a mailto: link. I want it to make either a popup, overlay or new window which has a simple form which allows anyone to email the link of the page they are on to another friend, with the subject and content pre-filled but editable. Something similar to how you can do it on google maps by clicking "Send"

I thought this would be simple to find and I would be amazed if no-one has made some sort of easy javascript plugin or something.

I would rather not use something like "addthis" or other similar sharing aggreator service.

I have looked around here and scoured google but cannot find anything. If I missed a topic or if there is a good tutorial it would be 开发者_JS百科much appreciated!


What you are asking for is only possible with server side code. Your server will need to have access to a mail server so that it can compose and send on behalf of your user. This has most definitely been prebuilt, but you will need to let us know what server side language you are using before someone can point you to a solution. If you don't understand server side code then you will have to resign yourself to using a mailto: link or a third party service.

UPDATE - Example

In your HTML

<form action="http://mysite.com/sendemail.php" method="post" name="myform" >
    <input name="from" type="text" value="me@mysite.com" />
    <input name="to" type="text" value="me@mysite.com" />
    <input name="subject" type="text" value"Subject" />
    <input name="body" type="text" value="Hello World" />
</form>

In your PHP file

$from = $_POST['from'] ;
$to = $_POST['to'];
$subject = $_POST['subject'] ;
$body = $_POST['body'] ;
mail($to, $subject, $body, "From:" . $from);

Because the form is set to method POST you can access each form element by its name and the _POST variable. So $_POST['from'] get the form elements whose name = "from".


For jQuery you can see the sharing plugins on offer here: http://plugins.jquery.com/plugin-tags/share

One of them sounds like what you need (Share Email):

A simple share this page via email plugin that grabs the page title, url, meta description and makes a mailto link with Subject and Body pre-filled.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜