1

I'm getting this error Warning: mail() Multiple or Malformed new lines found in additional header... I have tried giving the $message variables a different variable name, but nothing I do works.

There error is coming from the last line that I posted in this..

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

Full code

$to = $approved_email;
        $subject = 'There is a new user request to join the ';
        $message = '
        <html>
        <head>
            <title>New User Request</title>
        </head>
        <body>
            <p>Hi '.$approved_firstname.',</p><br>
            <p>Your  Account has been accepted. You have been added to the group. To sign in, click this link
            http://example.com . </p><br>
            <p>Thank you,</p>
            <p>Administration</p>
        </body>
        </html>
        ';

        $from = "user-requests@example.com";
        $Bcc = "user-requests-confirm@example.com";

        // To send HTML mail, the Content-type header must be set
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

        // Additional headers
        $headers .= 'To: ' .$to. "\r\n";
        $headers .= 'From: ' .$from. "\r\n";
        $headers .= 'Bcc: '.$Bcc. "\r\n";

        // Send the email
        mail($to,$subject,$message,$headers);

I have a similar email in another file and it works. What could be the problem?

Paul
  • 3,348
  • 5
  • 32
  • 76
  • two questions: where are you getting the error from and on what OS are you running the service? – Axel Amthor Jul 18 '15 at 07:41
  • 1
    Remove `To: ` from headers because it's not needed there. – hellcode Jul 18 '15 at 07:48
  • May be that, it is similar: http://stackoverflow.com/questions/30942998/php-mail-multiple-or-malformed-newlines-found – Zimmi Jul 18 '15 at 09:41
  • Took out the To: line and I do not get that error anymore, but the email does not send. I have a query above this email that is pulling an id and other info from an AJAX call. Would it be more beneficial to you all for me to add the other code? – Paul Jul 19 '15 at 01:26

0 Answers0