encode mailto: link


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. function encode_mailto($mail, $label, $subject = "", $body = "") {
  3. $chars = preg_split("//", $mail, -1, PREG_SPLIT_NO_EMPTY);
  4. $new_mail = "<a href=\"mailto:";
  5. foreach ($chars as $val) {
  6. $new_mail .= "&#".ord($val).";";
  7. }
  8. $new_mail .= ($subject != "" && $body != "") ? "?subject=".$subject."&body=".$body : "";
  9. $new_mail .= "\">".$label."</a>";
  10. return $new_mail;
  11. }
  12. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.