Why is it important to use \r\n instead of \n for line breaks in text emails?

Using \r\n instead of just \n for line breaks in text emails is important because different operating systems handle line breaks differently. \r\n represents a carriage return followed by a line feed, which is the standard line break sequence in emails and is recognized by most email clients. By using \r\n, you ensure that your emails are displayed correctly on all platforms.

$message = "Hello,\r\nThis is a test email.";
mail('recipient@example.com', 'Subject', $message);