在Symfony中加载Swift Mailer时出错

兰迪尔

我正在使用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.
Qooplmao

您的缩进是错误的。它应该像..

swiftmailer:
    transport: gmail
    username: '[email protected]'
    password: 'Mypassword'

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在Symfony中加载服务时出现RuntimeException

来自分类Dev

在MLMediaLibrary中加载媒体源时出错

来自分类Dev

在UIWebView中加载网站时出错

来自分类Dev

在Scala中加载本机库时出错

来自分类Dev

在Codeigniter hmvc中加载模型时出错

来自分类Dev

在pyaiml中加载AIML文件时出错

来自分类Dev

在Expo App中加载字体时出错

来自分类Dev

在MATLAB中加载文件时出错

来自分类Dev

在Android中加载小部件时出错

来自分类Dev

在yii中加载视图时出错

来自分类Dev

在pyaiml中加载AIML文件时出错

来自分类Dev

在Servlet中加载FCL文件时出错

来自分类Dev

在Lotusrb中加载资产时出错

来自分类Dev

在R中加载aplpack时出错

来自分类Dev

在sudo中加载共享库时出错

来自分类Dev

在 Angular Js 中加载模块时出错

来自分类Dev

在 Python 中加载 json 时出错

来自分类Dev

在 webpack 中加载 css 文件时出错

来自分类Dev

在Android Studio中加载项目时出错:无法加载模块

来自分类Dev

从Symfony中的Swift Mailer发送邮件时阻止邮件头

来自分类Dev

在dom php中加载文件时出错

来自分类Dev

在Sublime Text 3中加载配色方案时出错

来自分类Dev

在VS2008中加载OpenNETCF 2.3时出错

来自分类Dev

在IE9中加载JQueryUI 1.10.3时出错

来自分类Dev

在JavaFX项目中加载fxml文件时出错

来自分类Dev

在循环VB.Net中加载SQL参数时出错

来自分类Dev

从泡菜文件中加载multiprocessing.manager.dictionary时出错

来自分类Dev

在netlogo中加载栅格数据时出错

来自分类Dev

在Laravel 5中加载视图时出错