What are the differences between \n and \r\n for line breaks in PHP mail functions?

When sending emails using PHP mail functions, the line breaks should be specified correctly to ensure proper formatting in the email content. The "\n" character represents a line break in Unix-based systems, while "\r\n" represents a line break in Windows-based systems. Using the correct line break sequence based on the target system will ensure that the email content is displayed correctly.

// Set the line break based on the target system
$line_break = (PHP_OS == 'WINNT') ? "\r\n" : "\n";

// Use the line break in the email content
$email_content = "Hello,\nThis is a test email." . $line_break . "Thank you.";

// Send the email with correct line breaks
mail('recipient@example.com', 'Test Email', $email_content);