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: \r\n";
$headers .= 'Content-type: text/plain; charset=UTF-8';
$to = "";

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

About Ricard Torres

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.

@ricard_dev @ricard_dev

📝 Blog 🎙 Podcast

Leave a Reply

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