我的projet(symfony 2.8)上有swiftmailer的麻烦
当我自己创建传输器时,它可以工作,但是当我尝试加载swiftmailer配置时,它会失败。
所以我查看了$ mailer变量。
当我这样做时:
$transporter = \Swift_SmtpTransport::newInstance('myWebMail.com', 465, 'ssl')
->setUsername('user@test.com')
->setPassword('secret');
$mailer = \Swift_Mailer::newInstance($transporter);
我可以看到在调试时加载了conf:
Swift_Mailer::__set_state(array(
'_transport' =>
Swift_SmtpTransport::__set_state(array(
'_handlers' =>
array (
'AUTH' =>
Swift_Transport_Esmtp_AuthHandler::__set_state(array(
'_authenticators' =>
array (
0 =>
Swift_Transport_Esmtp_Auth_CramMd5Authenticator::__set_state(array(
)),
1 =>
Swift_Transport_Esmtp_Auth_LoginAuthenticator::__set_state(array(
)),
2 =>
Swift_Transport_Esmtp_Auth_PlainAuthenticator::__set_state(array(
)),
3 =>
Swift_Transport_Esmtp_Auth_NTLMAuthenticator::__set_state(array(
)),
4 =>
Swift_Transport_Esmtp_Auth_XOAuth2Authenticator::__set_state(array(
)),
),
'_username' => 'user@test.com',
'_password' => 'secret',
'_auth_mode' => NULL,
'_esmtpParams' =>
array (
),
)),
...
但是当我这样做时:
$mailer = $this->container->get('swiftmailer.mailer');
我有这个:
Swift_Mailer::__set_state(array(
'_transport' =>
Swift_Transport_EsmtpTransport::__set_state(array(
'_handlers' =>
array (
'AUTH' =>
Swift_Transport_Esmtp_AuthHandler::__set_state(array(
'_authenticators' =>
array (
0 =>
Swift_Transport_Esmtp_Auth_CramMd5Authenticator::__set_state(array(
)),
1 =>
Swift_Transport_Esmtp_Auth_LoginAuthenticator::__set_state(array(
)),
2 =>
Swift_Transport_Esmtp_Auth_PlainAuthenticator::__set_state(array(
)),
),
'_username' => 'user@test.com',
'_password' => 'secret',
'_auth_mode' => NULL,
'_esmtpParams' =>
array (
),
)),
),
我删除了app / cache文件夹 在我的parameter.yml中我有:
mailer_transport: smtp
mailer_host: myWebMail.com
mailer_port: 465
mailer_encryption: ssl
mailer_user: user@test.com
mailer_password: secret
在我的config.yml中:
swiftmailer:
default_mailer: default_mailer
mailers:
default_mailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
我错过了什么?
由于