How can the mail() function in PHP be used to set the priority of an email?
To set the priority of an email sent using the mail() function in PHP, you can include additional headers in the mail function call. The "X-Priority" header can be set to a value between 1 (highest) and 5 (lowest) to indicate the priority of the email. This allows you to prioritize important emails over less urgent ones.
$to = 'recipient@example.com';
$subject = 'Test Email with Priority';
$message = 'This is a test email with priority set.';
$headers = 'X-Priority: 1' . "\r\n";
$headers .= 'From: sender@example.com' . "\r\n";
mail($to, $subject, $message, $headers);
Keywords
Related Questions
- What are some potential pitfalls when trying to update values in a table and save them in a database using PHP?
- What are some common pitfalls to avoid when working with image manipulation and watermarking in PHP?
- How can the issue of a while loop leading to an infinite loop be resolved in the context of PHP regular expressions?