消息被假脱机但未发送

时间:2012-07-31 19:18:17

标签: symfony swiftmailer

我正在使用symfony2和swiftmailer发送一些示例消息,但它不起作用,消息在symfony / app / cache / swiftmailer / spool中假脱机但是当我执行commande php app / console swiftmailer:spool时:发送消息是从假脱机中删除但是没有发送,控制台中的输出是:发送0封电子邮件,有人可以告诉我哪里出问题?这是我的config.yml:

swiftmailer:
    transport:            smtp
    username:             ~
    password:             ~
    host:                 localhost
    port:                 false
    encryption:           ~
    auth_mode:            ~
    spool:
        type:                 file
        path:                 "%kernel.cache_dir%/swiftmailer/spool"
    sender_address:       ~
    antiflood:
        threshold:            99
        sleep:                0
    delivery_address:     ~
    disable_delivery:     ~
    logging:              "%kernel.debug%"

这是我的代码:

$message = \Swift_Message::newInstance()
    ->setSubject('Hello Email')
    ->setFrom('test@gmail.com')
    ->setTo('myadress@gmail.com')
    ->setBody($this->renderView('ProjetAccountBundle:Main:email.txt.twig'))
;
$this->get('mailer')->send($message);

return $this->render('ProjetAccountBundle:Main:test.html.twig');
}   

2 个答案:

答案 0 :(得分:0)

问题是使用smtp而不是mail,正确的配置文件是这样的:

swiftmailer:
    transport:            mail
    username:             ~
    password:             ~

答案 1 :(得分:-2)

swiftmailer:

spool: { type: memory }

您需要删除它。

相关问题