Br tag is not working in php mail

The <br> tag is an HTML tag, and it's not directly supported in plain text emails. When you send an email using PHP's mail() function, the content is sent as plain text, and HTML tags like <br> are not rendered as line breaks.

To achieve a line break in a plain text email, you can use a combination of newline characters (\n) and carriage returns (\r). Here are a few ways to do it:

  1. Use \n and \r:

    $message = "Hello,\n\rThis is a test email.\n\rBest regards,\n\rYour Name";

    This will create a line break between each \n and \r combination.

  2. Use PHP_EOL:

    $message = "Hello,". PHP_EOL. "This is a test email.". PHP_EOL. "Best regards,". PHP_EOL. "Your Name";

    PHP_EOL is a constant that represents the end-of-line character for your operating system (e.g., \n on Unix, \r\n on Windows).

  3. Use a library or framework: If you're using a PHP library or framework like PHPMailer or SwiftMailer, they often provide built-in support for HTML emails and can handle line breaks for you.

Here's an example using PHPMailer:

$mail = new PHPMailer();
$mail->setFrom('[email protected]');
$mail->addAddress('[email protected]');
$mail->Subject = 'Test Email';
$mail->Body = 'Hello,<br>This is a test email.<br>Best regards,<br>Your Name';
$mail->send();

In this example, the <br> tag is used to create a line break in the email body. PHPMailer will automatically convert the HTML content to a plain text representation.

Remember that when sending emails, it's essential to consider the recipient's email client and device, as well as the email's content type (plain text or HTML).