当处于产品模式时,电子邮件不会通过swiftmailer发送。在开发模式下,一切都按预期工作。这是我得到的日志文件:
编辑:编辑了隐私文件路径和域名,添加了行返回以便于阅读。确保SO格式化匹配的文件格式。
更新:我已经chmod -R 777 app / cache和app / log目录。使用dev仍然可以正常工作,但现在在prod中,没有错误记录到apache或app / log。电子邮件仍未发送。
[Sat Mar 14 20:57:03.896889 2015] [:error] [pid 31767] [client 216.99.32.6:54233]
PHP Fatal error:
Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host localhost [Connection refused #111]' in /my_project_path/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:259
Stack trace:
#0 /my_project_path/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php(64): Swift_Transport_StreamBuffer->_establishSocketConnection()
#1 /my_project_path/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(115):Swift_Transport_StreamBuffer->initialize(Array)
#2 /my_project_path/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php(74): Swift_Transport_AbstractSmtpTransport->start()
#3 /my_project_path/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/EventListener/EmailSenderListener.php(52): Swift_MemorySpool->flushQueue(Object(Swift_Transport_EsmtpTransport))
#4 [internal function]: Symfony\ in /my_project_path/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php on line 259, referer: https://example.com/admin/requests/view/277
我正在使用sendmail(在开发模式和symfony之外工作)。
我对于接下来的尝试感到迷茫,你能建议从哪里开始吗?
应用/配置/ config.yml
...
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
port: %mailer_port%
spool: { type: memory }
...
应用/配置/ parameters.yml
parameters:
...
mailer_transport: mail
mailer_host: localhost
mailer_user: ~
mailer_password: ~
mailer_port: ~
...
注意:将mailer_transport更改为“sendmail”会产生相同的结果。我怀疑这里有一个问题,因为这个文件在dev和prod之间应该是一致的。
应用/配置/ config_prod.yml
imports:
- { resource: config.yml }
#doctrine:
# orm:
# metadata_cache_driver: apc
# result_cache_driver: apc
# query_cache_driver: apc
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
nested:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
应用/配置/ config_dev.yml
imports:
- { resource: config.yml }
framework:
router: { resource: "%kernel.root_dir%/config/routing_dev.yml" }
profiler: { only_exceptions: false }
web_profiler:
toolbar: false
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
firephp:
type: firephp
level: info
assetic:
use_controller: true
#swiftmailer:
# delivery_address: me@example.com
网络/ app.php
use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
// Use APC for autoloading to improve performance
// Change 'sf2' by the prefix you want in order to prevent key conflict with another application
/*
$loader = new ApcClassLoader('sf2', $loader);
$loader->register(true);
*/
require_once __DIR__.'/../app/AppKernel.php';
//require_once __DIR__.'/../app/AppCache.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
$request = Request::createFromGlobals();
$request->trustProxyData();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
网络/ app_dev.php
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$request->trustProxyData();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
其他可能相关的信息: