How to add line break in php mail function?

Member

by domenico , in category: PHP General , a year ago

How to add line break in php mail function?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by darrion.kuhn , a year ago

@domenico 

To add a line break in the body of an email sent using the PHP mail() function, you can use the " " newline character sequence. Here is an example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
$to = "recipient@example.com";
$subject = "Hello";
$message = "Dear recipient, 
 This is a line break in an email sent using PHP mail function.";

$headers = 'From: sender@example.com' . "
" .
    'Reply-To: sender@example.com' . "
" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);


In this example, the " " sequence is used in the $message variable to create a line break. When the email is sent, the recipient will see the message displayed with a line break in the specified location.

Related Threads:

How to add a line break in woocommerce product titles on static pages?
How to create a line break in doxygen markdown?
How to automatically break line in tailwind css?
How to configure php mail in xampp?
How to use the break statement in PHP?
How to enable automatic page break in mpdf in php?