I want to Below Header to my function , How and where to add it ? $headers=""; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; My Function is : ( Where and How to add above Lines ) function sendEmail($email,$subject, $message) { $mail = null; $mail = new PHPMailer(true); // $mail->IsSMTP(); try { $mail->Host = "Host"; // SMTP server $mail->SMTPDebug = 0; // enables SMTP debug information (for testing) $mail->SMTPAuth = true; // enable SMTP authentication // sets the SMTP server $mail->Port = 25; // set the SMTP port for the GMAIL server $mail->Username ="username"; // SMTP account username $mail->Password = "apaaa"; // SMTP account password $mail->Priority = "1"; $mail->ConfirmReadingTo = ""; $mail->AddAddress($email); $mail->SetFrom('', 'XXXX'); $mail->Subject = $subject; $mail->MsgHTML($message); if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } //echo "Message has been sent"; } catch (Exception $e) { echo $e; } $mail->ClearAllRecipients(); } ?>
PHPMailer has a feature to add custom headers as defined here: https://phpmailer.github.io/PHPMailer/classes/PHPMailer.html#method_addCustomHeader Examples: $mail->addCustomHeader('X-custom-header', 'custom-value'); OR $mail->addCustomHeader('X-custom-header: custom-value'); So for you, you can add: $mail->addCustomHeader('MIME-Version: 1.0'); $mail->addCustomHeader('Content-Type: text/html; charset=ISO-8859-1');