Source for file function.mailto.php
Documentation is available at function.mailto.php
* Smarty {mailto} function plugin
* Purpose: automate mailto address link creation, and optionally
* - address = e-mail address
* - text = (optional) text to display, default is address
* - encode = (optional) can be one of:
* * none : no encoding (default)
* * javascript : encode with javascript
* * hex : encode with hexidecimal (no javascript)
* - cc = (optional) address(es) to carbon copy
* - bcc = (optional) address(es) to blind carbon copy
* - subject = (optional) e-mail subject
* - newsgroups = (optional) newsgroup(s) to post to
* - followupto = (optional) address(es) to follow up to
* - extra = (optional) extra tags for the href link
* @link http://smarty.php.net/manual/en/language.function.mailto.php {mailto}
* @author credits to Jason Sweat (added cc, bcc and subject functionality)
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
if (!empty($newsgroups)) {
if (!empty($followupto)) {
for ($i= 0; $i< count($mail_parms); $i++ ) {
$mail_parm_vals .= (0== $i) ? '?' : '&';
$mail_parm_vals .= $mail_parms[$i];
$address .= $mail_parm_vals;
} elseif (!in_array($encode,array('javascript','hex','none')) ) {
$smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex");
if ($encode == 'javascript' ) {
$string = 'document.write(\'<a href="mailto:'. $address. '" '. $extra. '>'. $text. '</a>\');';
for ($x= 0; $x < strlen($string); $x++ ) {
$js_encode .= '%' . bin2hex($string[$x]);
return '<script type="text/javascript" language="javascript">eval(unescape(\''. $js_encode. '\'))</script>';
} elseif ($encode == 'hex') {
$smarty->trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.");
for ($x= 0; $x < strlen($address); $x++ ) {
$address_encode .= '%' . bin2hex($address[$x]);
$address_encode .= $address[$x];
for ($x= 0; $x < strlen($text); $x++ ) {
$text_encode .= '&#x' . bin2hex($text[$x]). ';';
return '<a href="mailto:'. $address_encode. '" '. $extra. '>'. $text_encode. '</a>';
return '<a href="mailto:'. $address. '" '. $extra. '>'. $text. '</a>';
/* vim: set expandtab: */
|