1

Send apostrophe s ('s) in email message using was error encode using 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');
?>

When i open my email , i see peter’s ’s test

How can i send apostrophe s ('s) in email message using php ?

  • related: http://stackoverflow.com/questions/8421316/character-encoding-and-the-%C3%A2%E2%82%AC%E2%84%A2-issue – dramzy Jul 25 '15 at 16:33

2 Answers2

2

you need to use mb_convert_encoding on the string containing the apostrophe:

$message = mb_convert_encoding("peter’s test", 'UTF-8');
Ido Sarig
  • 341
  • 3
  • 11
0

You are using the character encoding charset=iso-8859-1 in your mail header. I used utf-8 and it worked fine. Try replacing charset=iso-8859-1 with charset=utf-8