我有一个使用SwiftMailer发送电子邮件的开发。
我有一个完美的开发服务器(使用PHP 5)
我有一个生产服务器,其中有PHP 7(并且服务器非常处女,配置很少),它提出了这些问题
电子邮件发送完好但邮件程序返回0.
我的电子邮件发送功能是:
public function sendEmail ($email) {
$transport = \Swift_MailTransport::newInstance("localhost", 25);
$mailer = \Swift_Mailer::newInstance($transport);
$message = \Swift_Message::newInstance("Recuperación de Contraseña");
if (isset($email["subject"]) && !empty($email["subject"])) {
$message->setSubject($email["subject"]);
}
if (isset($email["from"]) && !empty($email["from"])) {
$message->setFrom($email["from"]);
}
if (isset($email["to"]) && !empty($email["to"])) {
$message->setTo($email["to"]);
$message->setReadReceiptTo($email["to"]);
}
if (isset($email["embed_images"]) && !empty($email["embed_images"])) {
foreach ($email["embed_images"] as $embedImage_key=>$embedImage_value) {
if (!empty($embedImage_value)) {
$email["embed_images"][$embedImage_key] = $message->embed(\Swift_Image::fromPath($embedImage_value));
}
}
}
$email["parameters"] = array_merge($email["parameters"], array("embed_images" => $email["embed_images"]));
if (!isset($email["body"]) || empty($email["body"])) {
$message->setBody(
$this->renderView(
$email["template"],
$email["parameters"]
), 'text/html'
);
}
if (isset($email["attach_images"]) && !empty($email["attach_images"])) {
foreach ($email["attach_images"] as $attachImage_key=>$attachImage_value) {
if (!empty($attachImage_value)) {
$message->attach(Swift_Attachment::fromPath($attachImage_value));
}
}
}
$statusSend = true;
$logger = new \Swift_Plugins_Loggers_ArrayLogger;
//$logger = new \Swift_Plugins_Loggers_EchoLogger; //echo messages in real-time
$mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
if (!$mailer->send($message, $failures)) {
$statusSend = false;
echo "Failures:";
print_r($failures);
}
echo $logger->dump(); //not needed if using EchoLogger plugin
return $statusSend;
}
并通过
if (!$mailer->send($message, $failures)) {
是Swift_Mailer的问题吗?来自PHP?
由于