{mailto}

{mailto}

{mailto} automates the creation of mailto: links and optionally encodes them. Encoding e-mails makes it more difficult for web spiders to lift e-mail addresses off of your site.

Attribute NameTypeRequiredDefaultDescription
addressstringYesn/athe e-mail address
textstringNon/athe text to display, default is the e-mail address
encodestringNononeHow to encode the e-mail. Can be one of none, hex, javascript or javascript_charcode.
ccstringNon/ae-mail addresses to carbon copy. Separate entries by a comma.
bccstringNon/ae-mail addresses to blind carbon copy. Separate entries by a comma.
subjectstringNon/ae-mail subject.
newsgroupsstringNon/anewsgroups to post to. Separate entries by a comma.
followuptostringNon/aaddresses to follow up to. Separate entries by a comma.
extrastringNon/aany extra information you want passed to the link, such as style sheet classes

Technical Note: javascript is probably the most thorough form of encoding, although you can use hex encoding too.

Example 8-19. {mailto}

{mailto address="me@example.com"}
<a href="mailto:me@example.com" >me@example.com</a>

   {mailto address="me@example.com" text="send me some mail"}
<a href="mailto:me@example.com" >send me some mail</a>

   {mailto address="me@example.com" encode="javascript"}
<script type="text/javascript" language="javascript">
 eval(unescape('%64%6f% ... snipped ...%61%3e%27%29%3b'))
</script>

   {mailto address="me@example.com" encode="hex"}
<a href="mailto:%6d%65.. snipped..3%6f%6d">&#x6d;&..snipped...#x6f;&#x6d;</a>

   {mailto address="me@example.com" subject="Hello to you!"}
   <a href="mailto:me@example.com?subject=Hello%20to%20you%21" >me@example.com</a>

{mailto address="me@example.com" cc="you@example.com,they@example.com"}
   <a href="mailto:me@example.com?cc=you@example.com%2Cthey@example.com" >me@example.com</a>

{mailto address="me@example.com" extra='class="email"'}
   <a href="mailto:me@example.com" class="email">me@example.com</a>

{mailto address="me@example.com" encode="javascript_charcode"}
   <script type="text/javascript" language="javascript">
   <!--
{document.write(String.fromCharCode(60,97, ... snipped ....60,47,97,62))}
   //-->
   </script>

See also escape, Obfuscating E-mail Addresses and {textformat}

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.