How to add bullet in php mail

To add a bullet point in a PHP email, you can use HTML formatting in the email body. Here are a few ways to do it:

Method 1: Using HTML

You can use HTML to create a bullet point list in your email body. Here's an example:

$headers = 'MIME-Version: 1.0'. "\r\n";
$headers.= 'Content-type: text/html; charset=iso-8859-1'. "\r\n";

$message = '<html><body>';
$message.= '<ul>';
$message.= '<li>Item 1</li>';
$message.= '<li>Item 2</li>';
$message.= '<li>Item 3</li>';
$message.= '</ul>';
$message.= '</body></html>';

mail('[email protected]', 'Subject', $message, $headers);

In this example, we're using the <ul> and <li> HTML tags to create an unordered list with bullet points.

Method 2: Using PHP's nl2br function

You can use PHP's nl2br function to convert newline characters (\n) to HTML line breaks (<br>) and then add bullet points manually. Here's an example:

$headers = 'MIME-Version: 1.0'. "\r\n";
$headers.= 'Content-type: text/html; charset=iso-8859-1'. "\r\n";

$message = '• Item 1'. "\n";
$message.= '• Item 2'. "\n";
$message.= '• Item 3'. "\n";

$message = nl2br($message);

mail('[email protected]', 'Subject', $message, $headers);

In this example, we're using the nl2br function to convert the newline characters to HTML line breaks, and then adding the bullet points manually using the character.

Method 3: Using a library or framework

If you're using a PHP library or framework, such as PHPMailer or SwiftMailer, you can use their built-in functionality to create bullet point lists. For example, with PHPMailer:

$mail = new PHPMailer();
$mail->setFrom('[email protected]');
$mail->addAddress('[email protected]');
$mail->Subject = 'Subject';
$mail->Body = '<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>';
$mail->send();

In this example, we're using PHPMailer's Body property to set the email body as an HTML string, which includes a bullet point list.

Remember to set the Content-type header to text/html to ensure that the email body is rendered as HTML.