Search code examples
phpemailphp-5.4

Provider changes from PHP 5.3 to 5.4 - mail doesn't work anymore


since my provider changes to PHP 5.4 it seems, that my with php generated mails doesn't want to be sended anymore.

are there any changes to php mail with 5.4?

in 5.3 my code works fine:

$mime->setHTMLBody($html);
$mime->setTxtBody($text);
$pro_hdrs = array(
         'Content-Type'                 => 'text/html; charset=iso-8859-1',
         'Content-Transfer-Encoding'    => '8bit\r\n',
         'Date'                         => $mydate,
         'From'                         => '"Test"<[email protected]>',
         'To'                           => $email,
         'Reply-To'                     => $reply,
         'Subject'                      => $mysubject,
);
$pro_params["host"]     = 'somehost.com';
$pro_params["auth"]     = TRUE;
$pro_params["username"] = 'someuser';
$pro_params["password"] = 'somepw';
$body = $mime->get();
$pro_hdrs = $mime->headers($pro_hdrs);
 $pro_mail =& Mail::factory('smtp', $pro_params);
 $pro_mail->send($email, $pro_hdrs, $body);

Hope, you can give some help!

Cheers, Tom


Solution

  • Remove the & from the following line:

    $pro_mail =& Mail::factory('smtp', $pro_params);

    so it becomes:

    $pro_mail = Mail::factory('smtp', $pro_params);

    It is just deprecated. It is interesting that it did not raise an E_DEPRECATED error. If it is not your production environment you can enable those.