Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line Break in string for PHPMailer

Tags:

php

phpmailer

$bodyString = "$address\r\n\n\n$country\r\n\n\n$experience\r\n\n\n$message";
$mail->Subject = "$name : $email";
$mail->Body = $bodyString;

I m trying these \n to break the line but instead of getting line break I m getting spaces.
not working.

Given below is body I m getting in Mail

123 123 132 321 
like image 545
Prabhat Kashyap Avatar asked Oct 12 '25 10:10

Prabhat Kashyap


1 Answers

This way insert line breaks where newlines (\n) occur in the string:

<?php
    $bodyString =  nl2br("$address\n\n\n\n$country\n\n\n\n$experience\n\n\n\n$message");
?>
like image 128
Peyman.H Avatar answered Oct 14 '25 01:10

Peyman.H



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!