Tuesday 30 August 2011

Sending UTF-8 mail with PHP

I was facing issues sending mail encoded as UTF-8 via PHP. In order to do it properly, you need to set UTF-8 as the encoding for the mail function (first line of code below). Then, mail can be sent (second line).

mb_internal_encoding("UTF-8");
mb_send_mail( 'myrecipient@wherever.com', 'Polite subject', $message, $headers );