Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.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_Silex - Fatal编程技术网

Php SwiftMailer发送消息时崩溃

Php SwiftMailer发送消息时崩溃,php,silex,Php,Silex,我正试图通过SwiftMailer发送电子邮件,但它崩溃了,没有任何错误。 我四处搜索,发现很多人都有同样的问题,但我找到的任何解决方案都对我有帮助 我有以下代码: $transporter = \Swift_SmtpTransport::newInstance('webmail.xxx.xxx', 25) ->setUsername("XXXXXXX") ->setPassword("XXXXXX");

我正试图通过SwiftMailer发送电子邮件,但它崩溃了,没有任何错误。 我四处搜索,发现很多人都有同样的问题,但我找到的任何解决方案都对我有帮助

我有以下代码:

        $transporter = \Swift_SmtpTransport::newInstance('webmail.xxx.xxx', 25)
            ->setUsername("XXXXXXX")
            ->setPassword("XXXXXX");

        $mailer = \Swift_Mailer::newInstance($transporter);

        $message = \Swift_Message::newInstance('SUBJECT')
            ->setFrom(array('noreply@yoursite.com'))
            ->setTo(array('user@yoursite.com'))
            ->setBody('This is ma message man');

        $result = $mailer->send($message);
        echo "bla bla bla";
它没有到达回显/错误日志部分

我错过了什么? 我也在用silex

更新:

最初,我尝试了silex页面上的配置:

在index.php中配置swiftmailer选项并在控制器中发送电子邮件,但我遇到了错误:

PHP Fatal error:  Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host localhost [Connection refused #111]

因此,我尝试了另一种方法…

进入php.ini,打开“显示错误”和“错误报告”,然后重试。它已打开,但仍然没有错误: