Search code examples
phpphpmailernewlinemailer

PHP mailer not creating new lines


No matter what i try i can't create a new line with php mailer. It sends the letter jsut fine, though no new line.

$msg1 = 'Prašome užpildyti šią <a href="http://192.168.0.***/bni/anketa.php?data='.$data.'&git='.$val['mailid'].'">anketą</a>.';
$msg2 = ' http://192.168.0.***/bni/anketa.php?data='.$data.'&git='.$val['mailid'];
$mail->Body= $msg1 . "\r\n" . $msg2;
$mail->send();

Solution

  • You are mixing html and text content-type.

    Either use text only, where \r\n is fine, or use <br> which is for HTML which fits in your case (you also have <a href..).

    $mail->Body= $msg1 . "<br>" . $msg2;