My PHP script sends email to users and when the email arrives to their mailboxes, the subject line ($subject
) has characters like a^£
added to the end of my subject text. This is obviously and encoding problem. The email message content itself is fine, just the subject line is broken.
I have searched all over but can’t find how to encode my subject properly.
This is my header. Notice that I’m using Content-Type
with charset=utf-8
and Content-Transfer-Encoding: 8bit
.
//set all necessary headers
$headers = "From: $sender_name<$from>
";
$headers .= "Reply-To: $sender_name<$from>
";
$headers .= "X-Sender: $sender_name<$from>
";
$headers .= "X-Mailer: PHP4
"; //mailer
$headers .= "X-Priority: 3
"; //1 UrgentMessage, 3 Normal
$headers .= "MIME-Version: 1.0
";
$headers .= "X-MSMail-Priority: High
";
$headers .= "Importance: 3
";
$headers .= "Date: $date
";
$headers .= "Delivered-to: $to
";
$headers .= "Return-Path: $sender_name<$from>
";
$headers .= "Envelope-from: $sender_name<$from>
";
$headers .= "Content-Transfer-Encoding: 8bit
";
$headers .= "Content-Type: text/plain; charset=UTF-8
";
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…