2008
Jun 6

Ever had problems with german umlaut and data from mysql in mail subject and mail text?
Here is my solution:
 
//mailheader ….
$mailheader =’MIME-Version: 1.0′ .”\n”;
$mailheader.=’From: from@domain.net’ . “\n”;
$mailheader.=’Reply-To: to@domain.net’ . “\r\n”;
$mailheader.=’X-Mailer: PHP/’ . phpversion().”\n”;
// Next Line solves only the utf-8 problem within the mail text
$mailheader.=”Content-Type: text/plain; charset=UTF-8\n”;
$mailheader.=”Content-transfer-encoding: 8bit\n”;
// The subject needs to be ASCII 7 Bit
// First: decode utf-8 Data from myql database
$subject=”Example Mail für: “.utf8_decode($firstname.” “.$secondname);
// second: encode subject to ASCII
$subject=mb_encode_mimeheader( $subject, mb_internal_encoding(),”B”,”\n”);
$mailtext=”…….
–snip–
mail(‘address@domain.net, $subject, $mailtext, $mailheader);

Leave a Comment




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.