Home >Backend Development >PHP Tutorial >How to Send UTF-8 Emails Using PHP?
Sending UTF-8 Email with PHP
Sending emails with non-English characters can lead to garbled or missing text. This issue occurs when the email's encoding is not set to UTF-8.
To resolve this, you can add the header "Content-Type: text/html; charset=UTF-8" to your message body.
Using the mail() Function
$headers = "Content-Type: text/html; charset=UTF-8"; mail($to, $subject, $message, $headers);
In this code, $headers is the fourth parameter.
Using PEAR Mail::factory()
$smtp = Mail::factory('smtp', $params); $headers = ["Content-Type: text/html; charset=UTF-8"]; $mail = $smtp->send($to, $headers, $body);
The above is the detailed content of How to Send UTF-8 Emails Using PHP?. For more information, please follow other related articles on the PHP Chinese website!