note 92976 modified in function.mail by danbrown

From: Date: Mon, 17 Aug 2009 18:31:42 +0000
Subject: note 92976 modified in function.mail by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159580@lists.php.net to get a copy of this message
UTF-8 and QMail This function should work for all of you, who want to switch to UTF-8 email - especially if using Qmail as Mailserver. QMail seems to have problems with the "\r\n" in the header section. I found it helpful to replace them with "\n". <?php function mail_utf8($to, $subject = '(No subject)', $message = '', $from) { $header = 'MIME-Version: 1.0' . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'From: Yourname <' . $from . ">\n"; mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header); } ?> --was-- (this corrects my previous mail, function was wrong. I find this notable as none of the other functions listed here worked - nor any I googled) UTF-8 and QMail This function should work for all of you, who want to switch to UTF-8 email - especially if using Qmail as Mailserver. QMail seems to have problems with the "\r\n" in the header section. I found it helpful to replace them with "\n". function mail_utf8($to, $subject = '(No subject)', $message = '', $from) { $header = 'MIME-Version: 1.0' . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'From: Yourname <' . $from . ">\n"; mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header); } http://php.net/manual/en/function.mail.php

« previous php.notes (#159580) next »