Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Swiftmailer在登台后出现故障_Php_Laravel_Smtp_Swiftmailer_Mandrill - Fatal编程技术网

Php Swiftmailer在登台后出现故障

Php Swiftmailer在登台后出现故障,php,laravel,smtp,swiftmailer,mandrill,Php,Laravel,Smtp,Swiftmailer,Mandrill,我正在为即将到来的活动创建一个最新的网站(基于Laravel)。其中一部分是改进了邮件功能,为此我决定将Mandrill的SMTP与SwiftMailer结合使用。在本地工作时,一切都很好。然而,由于我们将所有内容都推到了一个活动(好吧,测试,但与活动在同一台服务器上)暂存区域,因此不再发送邮件 在我用PHP发出send()命令后,一切似乎都崩溃了。即使是一个简单的print命令也没有任何作用。也没有报告错误,除非我在控制台中查看,请求返回500个内部服务器错误,没有任何其他错误 目前,这些是我

我正在为即将到来的活动创建一个最新的网站(基于Laravel)。其中一部分是改进了邮件功能,为此我决定将Mandrill的SMTP与SwiftMailer结合使用。在本地工作时,一切都很好。然而,由于我们将所有内容都推到了一个活动(好吧,测试,但与活动在同一台服务器上)暂存区域,因此不再发送邮件

在我用PHP发出send()命令后,一切似乎都崩溃了。即使是一个简单的print命令也没有任何作用。也没有报告错误,除非我在控制台中查看,请求返回500个内部服务器错误,没有任何其他错误

目前,这些是我用来测试的功能,它可以在本地完美地工作和发送,然后打印,但是在暂存区会出现一个白色的屏幕

Route::any('test', function()
{
    testMail();
    //this print works perfectly locally but shows nothing on staging
    print ('boe');
});

function testMail(){
$to         = array('private@email.address' => 'My Name');
$subject    = 'test mail';
$text       = "test mail hier";
$htmlTekst  = "<b>boe</b><i>spaghetti</i>";
$view = View::make('mailTemplate', 
    ['naam' => 'Jeroen Cuvelier', 
    'tekst' => $htmlTekst, 
    'username' => 'my email address', 
    'password' => 99999, 
    'siteUrl' => rootUrl(), 
    'header2' => '']);
$html = $view->render();
sendEmail($text, $html, $to, $subject, "", "");}



function sendEmail($text, $html, $to, $subject, $attachment, $attachmentName)
{
    //$subject = 'Subject!';

    $from       = array('event@email.company' =>'Company event');

    /*
    SMTP-settings
    */
    $transport  = Swift_SmtpTransport::newInstance('smtp.mandrillapp.com', 25);
    $transport->setUsername('MY_MANDRILL_USERNAME');
    $transport->setPassword('MY_MANDRILL_PASSWORD');
    $swift      = Swift_Mailer::newInstance($transport);

    $message    = new Swift_Message($subject);
    $message->setFrom($from);
    $message->setBody($html, 'text/html');
    $message->setTo($to);
    $message->addPart($text, 'text/plain');

    if ($attachment != "")
    {
        $toAttach = Swift_Attachment::fromPath($attachment);
        if ($attachmentName!="")
        {
            $toAttach->setFilename($attachmentName);
        }
        $message->attach($toAttach);
    }

    //neither of these messages print on staging
    if ($recipients = $swift->send($message, $failures))
    {
     echo 'Message successfully sent!';
    } else {
     echo "There was an error:\n";
     print_r($failures);
    }
}
Route::any('test',function())
{
testMail();
//这张照片在本地效果很好,但在舞台上没有显示任何内容
印刷品(“boe”);
});
函数testMail(){
$to=数组('private@email.address“=>”我的名字“;
$subject='testmail';
$text=“测试邮件hier”;
$htmlTekst=“意大利面”;
$view=view::make('mailTemplate',
['naam'=>'Jeroen Cuvelier',
“tekst”=>htmlTekst美元,
“用户名”=>“我的电子邮件地址”,
“密码”=>99999,
'siteUrl'=>rootUrl(),
“header2'=>”);
$html=$view->render();
sendEmail($text,$html,$to,$subject,“,”);}
函数sendmail($text、$html、$to、$subject、$attachment、$attachmentName)
{
//$subject='subject!';
$from=数组('event@email.company“=>”公司事件“);
/*
SMTP设置
*/
$transport=Swift\u SmtpTransport::newInstance('smtp.mandrillapp.com',25);
$transport->setUsername('MY_MANDRILL_USERNAME');
$transport->setPassword('MY_MANDRILL_PASSWORD');
$swift=swift\u Mailer::newInstance($transport);
$message=新的Swift_消息($subject);
$message->setFrom($from);
$message->setBody($html,'text/html');
$message->setTo($to);
$message->addPart($text,'text/plain');
如果($attachment!=“”)
{
$toAttach=Swift\u附件::fromPath($Attachment);
如果($attachmentName!=“”)
{
$toAttach->setFilename($attachmentName);
}
$message->attach($toAttach);
}
//这两条消息都不会在登台时打印
如果($recipients=$swift->send($message,$failures))
{
回显“消息已成功发送!”;
}否则{
echo“出现错误:\n”;
打印(失败);
}
}

结果表明问题不在PHP或我所做的任何事情中。服务器不允许SMTP呼叫。打电话给主机公司解决了我的问题。

结果发现问题不在PHP或我做的任何事情中。服务器不允许SMTP呼叫。打电话给公司解决了我的问题