How can line breaks in emails be controlled when using PHP's mail function?
When using PHP's mail function to send emails, line breaks can be controlled by using the "\r\n" sequence to indicate a new line. This ensures that the email content is formatted correctly with proper line breaks.
$to = "recipient@example.com";
$subject = "Test Email";
$message = "Hello,\r\nThis is a test email.\r\nRegards,";
$headers = "From: sender@example.com\r\n";
mail($to, $subject, $message, $headers);
Keywords
Related Questions
- Why is using SELECT * in SQL queries discouraged and what are the alternatives for specifying columns in PHP?
- When using sessions in PHP, what are the potential pitfalls or errors that may arise, especially when working with Joomla?
- What are the advantages and disadvantages of using SimpleXML for parsing and manipulating XML data in PHP?