note 124291 added to function.mail

From: Date: Sat, 12 Oct 2019 07:36:54 +0000
Subject: note 124291 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-212580@lists.php.net to get a copy of this message
If you notice wrong displayed characters in the email it's because you need to properly set the Content-Type and the Charset in the headers of the email: <?php $headers = 'Content-Type: text/plain; charset=utf-8' . "\r\n"; ?> Mostly, UTF-8 is your best choice. You can set custom headers with the fourth parameter of the mail() function. To make the whole thing waterproof, add the following header too: <?php $headers .= 'Content-Transfer-Encoding: base64' . "\r\n"; ?> Now you can use the combination of UTF-8 and Base64 to properly encode the subject line and the recipient name like this: <?php $subject = '=?UTF-8?B?' . base64_encode('Test email with German Umlauts öäüß') . '?='; $recipient = '=?UTF-8?B?' . base64_encode('Margret Müller') . '?= <recipient@domain.com>'; ?> And don't forget to Base64 encode the email message too: <?php $message = base64_encode('This email contains German Umlauts öäüß.'); ?> All references are taken from: https://dev.to/lutvit/how-to-make-the-php-mail-function-awesome-3cii ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.168 (proxied: 2001:16b8:186a:a300:9d4d:d1cc:310:5753) ---- Manual Page -- http://php.net/manual/en/function.mail.php Edit -- https://master.php.net/note/edit/124291 Del: integrated -- https://master.php.net/note/delete/124291/integrated Del: useless -- https://master.php.net/note/delete/124291/useless Del: bad code -- https://master.php.net/note/delete/124291/bad+code Del: spam -- https://master.php.net/note/delete/124291/spam Del: non-english -- https://master.php.net/note/delete/124291/non-english Del: in docs -- https://master.php.net/note/delete/124291/in+docs Del: other reasons-- https://master.php.net/note/delete/124291 Reject -- https://master.php.net/note/reject/124291 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#212580) next »