jbcarey Posted July 15, 2008 Share Posted July 15, 2008 Hello all, First of, my php isn't good at all... My googling on the other hand is, but I haven't been able to find an answer to my question. I'm working on a major site, shown in all European countries (or most of them) and the tricky thing is... The entities... They all show up correctly on the website in the browser... But once viewed in any mail (hotmail, Mail on a mac... things don't come out correctly.... Here's my code.... can anyone find a way to fix it? /** * Send activation mail to new registrant. * Returns boolean 'true' on success, or 'false' if the mail didn't get sent. */ function sendActivationMail($email = '') { if (! empty($email)) { if (!preg_match('/^[a-z]\w*(\.\w[a-z0-9-]*)*@\w[a-z0-9-]*(\.\w[a-z0-9-]*)*\.[a-z]{2,6}$/i', $email)) return false; $this->formFields['email']['value'] = $email; } $activationlink = ROOT_URL.'/register.php?activate='.md5($this->formFields['email']['value']); $from = ADMIN_EMAIL; $to = $this->formFields['email']['value']; $subject = USR_MAIL_SUBJECT; $message = USR_MAIL_MESSAGE."\n".$activationlink; $headers = "From: ".$from."\r\n"; $sent = mail($to, $subject, $message, $headers); return $sent; } Here to swift help. Link to comment https://forums.phpfreaks.com/topic/114809-emailentitieslanguage-files/ Share on other sites More sharing options...
jbcarey Posted July 15, 2008 Author Share Posted July 15, 2008 i feel like a doorknob.... I was looking in the wrong function this is register... I was looking in forgot password Anyways.... the correct way to do this for anyone else is using html_entity_decode() after all. /** * Send activation mail to new registrant. * Returns boolean 'true' on success, or 'false' if the mail didn't get sent. */ function sendActivationMail($email = '') { if (! empty($email)) { if (!preg_match('/^[a-z]\w*(\.\w[a-z0-9-]*)*@\w[a-z0-9-]*(\.\w[a-z0-9-]*)*\.[a-z]{2,6}$/i', $email)) return false; $this->formFields['email']['value'] = $email; } $activationlink = ROOT_URL.'/register.php?activate='.md5($this->formFields['email']['value']); $from = ADMIN_EMAIL; $to = $this->formFields['email']['value']; $subject = html_entity_decode(USR_MAIL_SUBJECT); $message = html_entity_decode(USR_MAIL_MESSAGE)."\n".$activationlink; $headers = "From: ".$from."\r\n"; $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/plain;charset=iso-8859-1" . "\r\n";// More headers $sent = mail($to, $subject, $message, $headers); return $sent; } My working Code. note the subject and message. Link to comment https://forums.phpfreaks.com/topic/114809-emailentitieslanguage-files/#findComment-590349 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.