Recipe 7.8. Putting Additional Information in mailto Links


You need to pre-format an email message generated from a link on your web site.


Extend the mailto link to include values for the message subject, body, and additional recipients.

A basic mailto link on a web page creates a new email message in the user's default email application. It's a good idea to make the actual address the link, because that helps reinforce for the user what happens when she selects the link:

 <a href=""></a> 

You can create more complex links that fill in parts of the message. With Subject and Body, you can ensure at least some meaningful content in the email messages you receive from your site:

 <a href="    web site%20comment&Body=Type%20your%20message%20here:"></a> 

The characters %20 indicate a space in the encoded URL, though most browsers can handle an unencoded space.

You also can add additional recipients in the To:, Cc:, and Bcc: headers of the message by separating their addresses with commas:

 <a href=","></a> 


Unprotected email addresses in web page code are like blood in the water for spam sharks. If you must use linked email addresses on your site (rather than an email form that hides actual addresses), be sure to read Recipe 9.11 for more information. Most of the protection techniques described in that Recipe will still allow you to add the additional information to your email links described in this Recipe. On the positive side, however, pre-formatting prevents email messages from your web site from being rejected as spam before they get to you. A preset email subject line can help spam filters recognize a message sent from your web site as legitimate.

See Also

Recipe 9.11 will help you use these techniques and still keep a clean inbox.

Web Site Cookbook.
Web Site Cookbook: Solutions & Examples for Building and Administering Your Web Site (Cookbooks (OReilly))
ISBN: 0596101090
EAN: 2147483647
Year: N/A
Pages: 144
Authors: Doug Addison

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: