Content Type mail PHP

When using the mail PHP function to send e-mails one think you should not forget is the Content Type.

I had my contact form wich was sending me e-mails. When somebody was writing in spanish using: ó í the mail was broke up.

The solution is use the UTF-8 charset.

This is the way you should send an e-mail:

$headers = "From: me@gmail.com \r\n";
$headers .= 'Content-type: text/plain; charset=UTF-8';
$to = "my_friend@gmail.com";

mail($to, "Subject", "Cool Message", $headers);

About Rick

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*