1

我正在尝试使用 Silex 和 SwiftMailer 设置邮件脚本。但是,到目前为止,我还没有设法将邮件发送出去。设置swiftmailer.use_spool为 时false,我不会收到错误消息,但也不会收到电子邮件。当像这样刷新假脱机传输队列时......

if ($app['mailer.initialized']) {
    $app['swiftmailer.spooltransport']
        ->getSpool()
        ->flushQueue($app['swiftmailer.transport']);
}

...我得到以下异常:

Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host abc.xyz [ #0]'

到目前为止,我还没有找到任何有关此异常的文档。我确定所有 SMTP 设置和凭据都有效(我也尝试了另一台主机,同样的问题)。我还可以 ping 主机,并且我使用的端口是打开的,并且php_openssl已启用。

看起来它失败了,Swift\Transport\StreamBuffer.php:269因为stream_socket_client返回 0:

$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
if (false === $this->_stream) {
    throw new Swift_TransportException(
        'Connection could not be established with host '.$this->_params['host'].
        ' ['.$errstr.' #'.$errno.']'
        );
}

更新 #1 我忘了查看错误日志,现在我看到它说:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/php_openssl.dll' - /usr/lib/php5/20121212/php_openssl.dll: cannot open shared object file: No such file or directory in Unknown on line 0

所以似乎 PHP 无法加载 php_openssl 扩展,虽然phpinfo()说该模块已启用?它应该在哪里,或者我应该如何获得它?

更新 #2 我相信我可能错误地尝试启用php_openssl.dll适用于 Windows 环境的扩展。当我删除它时,错误显然从错误日志中消失了,但主要问题仍然存在。回到原点..

我可能做错了什么?

4

0 回答 0