How can PHP be configured to send emails in plain text format rather than HTML format for better compatibility with certain email clients like Outlook?
To configure PHP to send emails in plain text format rather than HTML format for better compatibility with certain email clients like Outlook, you can set the content type of the email to "text/plain" in the email headers. This will ensure that the email is sent as plain text rather than HTML.
<?php
$to = "recipient@example.com";
$subject = "Test Email";
$message = "This is a plain text email.";
$headers = "From: sender@example.com\r\n";
$headers .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);
?>
Keywords
Related Questions
- What are the best practices for handling database connections in PHP scripts, especially in the context of user authentication?
- How can PHP be used to efficiently separate, order, and insert data into a MySQL database from externally sourced JSON data?
- How can the "Fatal error: Call to a member function attributes() on a non-object" error be resolved in PHP when working with XML?