Search code examples
phpphpmailer

PHPMailer - Trying to set new line while sending emails


I've connected PHPMailer to my register system and once a user registers it auto-sends a email to the registered user, now I'm having a issue while attempting to set a new line while sending the email:

"Hello, ".$formvars['name']."<br>".
     "Thank you for your registration with us and trusting us with your user account!"."<br>".
     "If any problems arrise with logging into your account or using it, please adress this email."."<br>".
     "\n".
     "Kind Regards."."<br>".
     "Auto-Bot!"."<br>";

I don't really see why it wouldn't make a new line properly, the \n or \r\n don't show in the email but also don't make a new line.

UPDATE:

Apologize for not providing enough code, the issue was that I called isHTML and tried to do that, I changed the lines to split up using


Solution

  • At a guess (because you didn't post your code), you're probably sending plain text as HTML, and HTML will ignore line breaks, so omit this line from your code:

    $mail->isHTML();
    

    If you want to use HTML, you can use HTML tags such as <p> and <br> to break up your text.