0

我想用 Symfony SwiftMail 和一个 Gandi (roundcube) 地址发送一封电子邮件。问题是什么都没有发生,我不知道为什么。^^

配置.yml

swiftmailer:
    transport: mail
    encryption: ssl
    auth_mode:  login
    host:      smtp
    username:  'my email'
    password:  'my mdp'

参数.yml

parameters:
    mailer_transport: smtp
    mailer_host: 127.0.0.1:160
    mailer_user: null
    mailer_password: null

控制器:

public function contactAction()
{
    $mail = "mymail";
    $enquiry = new Contact();
    $form = $this->createForm(new EnquiryType(), $enquiry);

    $request = $this->getRequest();
    if ($request->getMethod() == 'POST')
    {
        $form->bind($request);
        $data = $form->getData();

        $message = \Swift_Message::newInstance()
            ->setContentType('text/html')
            ->setSubject($data->getSubject())
            ->setFrom($data->getAdresse())
            ->setTo($mail)
            ->setBody($data->getMessage());
        $this->get('mailer')->send($message);

        return $this->redirect($this->generateUrl('st_contact_homepage'));
    }
    return $this->render('STCommonBundle:Default:contact.html.twig', array('form' => $form->createView()));
}

你能帮我吗?

谢谢。^^

4

1 回答 1

0

你的配置似乎是错误的

“主机”属性必须是 smpt 主机名

喜欢

smpt.yahoo.com

你需要找出来

并且运输是smpt

所以宁愿这样:

swiftmailer:
    transport: smtp
    encryption: ssl
    auth_mode:  login
    host:      smtp.yahoo.com
    username:  'my email'
    password:  'my mdp'
于 2015-11-23T14:17:06.037 回答