What are the potential pitfalls of using nl2br() function when sending text emails in PHP?
Using nl2br() function when sending text emails in PHP can potentially lead to unexpected line breaks being displayed in email clients that do not support HTML. To avoid this issue, it's recommended to use the PHP_EOL constant to insert line breaks instead, which will ensure consistent formatting across different email clients.
// Use PHP_EOL for line breaks instead of nl2br()
$message = "Hello," . PHP_EOL . "This is a test email.";
// Send email using the $message variable