在电子邮件中使用was错误编码发送撇号(';s)是否使用PHP?
在电子邮件消息中发送撇号s(在电子邮件中使用was错误编码发送撇号(';s)是否使用PHP?,php,email,Php,Email,在电子邮件消息中发送撇号s(),是否使用was错误编码使用PHP <?PHP include("connect.php"); $to = "example@example.com"; $subject = "TEST SUBJECT"; $message = "peter’s test"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-
),是否使用was错误编码使用PHP
<?PHP
include("connect.php");
$to = "example@example.com";
$subject = "TEST SUBJECT";
$message = "peter’s test";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: EXAMPLE <noreply@example.com>' . "\r\n";
$headers .= 'Return-Path: return@example.com' . "\r\n";
mail($to, $subject, $message, $headers, '-freturn@example.com');
?>
当我打开我的电子邮件时,我看到了彼得的™s测试
如何使用php在电子邮件中发送撇号s(
)?您需要对包含撇号的字符串使用mb\u convert\u编码:
$message = mb_convert_encoding("peter’s test", 'UTF-8');
您正在邮件头中使用字符编码charset=iso-8859-1。我用了utf-8,效果很好。尝试将
charset=iso-8859-1
替换为charset=utf-8
相关: