Archive

Archive for May, 2010

How to send UTF8 encoded mail in php

May 24, 2010 Leave a comment

After some of my foreign language emails were coming out strange I had a look around to find a way to send out mails through the mail function in PHP.. here it is:


$headers = "MIME-Version: 1.0" . "\r\n" . "Content-type: text/plain; charset=UTF-8" . "\r\n";
mail($to, "=?UTF-8?B?".base64_encode($subject)."?=", $message, $headers);

You can use this method to utf encode the sender/recipient/message. Be sure to change text/plain to text/html if you are sending html in a mail 🙂

Categories: PHP