我正在使用swift mailer为我的symfony应用程序发送电子邮件。但是它抛出了错误:没有扩展程序能够加载“ transport”的配置。加载应用程序崩溃的配置文件时出现错误。请帮助我知道如何精确定义它的配置参数。我的app / config.yml是这样的:
swiftmailer:
transport: gmail
username: '[email protected]'
password: 'Mypassword'
我还检查了app / Appkernel.php swiftmailer捆绑包是否已经注册:
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Acme\SuperbAppBundle\AcmeSuperbAppBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
我正在使用以下代码发送电子邮件:
$message = \Swift_Message::newInstance()
->setSubject('Hello Email') // we configure the title
->setFrom('[email protected]') // we configure the sender
->setTo('[email protected]') // we configure the recipient
->setBody("Hello User");
$send = $this->get('mailer')->send($message); // then we send the message.
您的缩进是错误的。它应该像..
swiftmailer:
transport: gmail
username: '[email protected]'
password: 'Mypassword'
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句