ProblemYou need to pre-format an email message generated from a link on your web site. SolutionExtend 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="mailto:address@domain.com">address@domain.com</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="mailto:address@domain.com?Subject= web site%20comment&Body=Type%20your%20message%20here:"> address@domain.com</a>
You also can add additional recipients in the To:, Cc:, and Bcc: headers of the message by separating their addresses with commas: <a href="mailto:address@domain.com,another@domain.com& Cc:afriend@domain.com&Bcc:someone@domain.com">address@domain.com</a> DiscussionUnprotected 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 AlsoRecipe 9.11 will help you use these techniques and still keep a clean inbox. |