Symfony2 SwiftMailer sendmail传输错误 [英] Symfony2 SwiftMailer sendmail transport error

查看:177
本文介绍了Symfony2 SwiftMailer sendmail传输错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在我的网站上实施联系表单。
i遵循symfony2文档: http://symfony.com/我使用symfony 2.3.3。

这就是我的config_dev.yml:

  swiftmailer:
transport:sendmail

我的contactAction控制器:

  public function contactAction(Request $ request)
{
$ this-> focus =contact;
$ b $ form = $ this-> createFormBuilder()
- > add('Sujet:','text')
- > add('Service:' ,'choice',
数组(
'choices'=>
数组(
'all'=>'通信多信道(plusieurs servicesliés)',
'web'=>'DéveloppementWeb',
'webMarketing'=>'网络营销',
'mobile'=>'Développementmobile / tablette',
'brand'=>'Brand design',
'event'=>'Evènementiel',
'print'=>'Campagne print',
),

'preferred_choices'=>数组('all'),


- > add('Nom:','text')
- > add('Societe:','text')
- > add('Courriel:',''电子邮件')
- > add('message:','textarea')
- > getForm();

$ form-> handleRequest($ request);
$ b $ if if($ form-> isValid()){
// LesDonnéessont un tableau avec lesclésname,email,etmessage
$ data = $ form-> getData();
$ message = \Swift_Message :: newInstance()
- > setSubject($ data ['Sujet']。$ data ['Société'])
- > setFrom($数据['Courriel'])
- > setTo('contact@visual-immersion.com')
- > setBody($ this-> renderView('textàplacer par la suite' ))
;
$ this-> get('mailer') - > send($ message);


$ this-> get('mailer') - > send($ message);
return $ this-> render('VisualImmersionSiteBundle:Site:contact.html.twig',
array(
'focus'=> $ this-> focus,
'form'=> $ form-> createView(),
));
}

我有这个错误:


可捕获的致命错误:将参数2传递给
Swift_Transport_SendmailTransport :: __ construct()必须实现
接口Swift_Events_EventDispatcher,
的实例Swift_Transport_StreamBuffer给出, b $ b /var/www/visual-immersion/app/cache/dev/appDevDebugProjectContainer.php
在2129行,并在
/ var / www / visual-immersion / vendor / swiftmailer / swiftmailer / lib / classes / Swift / Transport / SendmailTransport.php
line 42


我绝对找不到问题所在。您有任何想法,或者您遇到过这个错误吗?



感谢您的帮助

更新:

我将SwiftMailer软件包降级到作曲家的2.3.2版本。这个问题已经解决了,但是现在,我有这个错误信息;


预期的响应代码220但是代码,带有

有什么想法吗?

解决方案

原因是您服务器中的sendmail函数不正确。

您可以使用命令测试:telnet localhost 25



如果您使用的是Linux服务器。您应该安装Postfix,因为SSMTP不支持telnet,而SwitfMailer在发送电子邮件之前始终检查telnet。


I wish implementer a contact form on my website. i followed the symfony2 documentation : http://symfony.com/fr/doc/current/cookbook/email/email.html

i use symfony 2.3.3.

So that is my config_dev.yml:

swiftmailer:
    transport: sendmail

My contactAction controller:

 public function contactAction(Request $request)
    {
        $this->focus = "contact";

        $form = $this->createFormBuilder()
            ->add('Sujet:', 'text')
            ->add('Service:', 'choice',
                array(
                    'choices' =>
                        array(
                            'all' => 'Communication multi-canaux (plusieurs services liés)',
                            'web' => 'Développement Web',
                            'webMarketing' => 'Web Marketing',
                            'mobile' => 'Développement mobile / tablette',
                            'brand' => 'Brand design',
                            'event' => 'Evènementiel',
                            'print' => 'Campagne print',
                        ),

                    'preferred_choices' => array('all'),
                )
            )
            ->add('Nom:', 'text')
            ->add('Societe:', 'text')
            ->add('Courriel:', 'email')
            ->add('message:', 'textarea')
            ->getForm();

        $form->handleRequest($request);

        if ($form->isValid()) {
            // Les données sont un tableau avec les clés "name", "email", et "message"
            $data = $form->getData();
            $message = \Swift_Message::newInstance()
                ->setSubject($data['Sujet'] . $data['Société'])
                ->setFrom($data['Courriel'])
                ->setTo('contact@visual-immersion.com')
                ->setBody($this->renderView('text à placer par la suite'))
            ;
            $this->get('mailer')->send($message);
        }

        $this->get('mailer')->send($message);
        return $this->render('VisualImmersionSiteBundle:Site:contact.html.twig',
            array(
                'focus' => $this->focus,
                'form'   => $form->createView(),
            ));
    }

i have this error:

Catchable Fatal Error: Argument 2 passed to Swift_Transport_SendmailTransport::__construct() must implement interface Swift_Events_EventDispatcher, instance of Swift_Transport_StreamBuffer given, called in /var/www/visual-immersion/app/cache/dev/appDevDebugProjectContainer.php on line 2129 and defined in /var/www/visual-immersion/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php line 42

and I absolutely can not find where the problem is. Do you have any ideas, or have you experienced this error?

Thank you for your help

UPDATE:

i downgraded SwiftMailer package to 2.3.2 version in composer. The problem was solved, but now, i have this error message;

Expected response code 220 but got code "", with message ""

any idea ?

解决方案

The reason is the sendmail function in your server is not correct.

You can test with command: telnet localhost 25

If you are using Linux server. You should install Postfix, because SSMTP does not support telnet, while SwitfMailer always check telnet before sending email.

这篇关于Symfony2 SwiftMailer sendmail传输错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆