Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony 消息是假脱机的,但不发送_Symfony_Swiftmailer - Fatal编程技术网

Symfony 消息是假脱机的,但不发送

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

我正在使用symfony2和swiftmailer发送一些示例消息,但它不起作用,消息在symfony/app/cache/swiftmailer/spool中进行假脱机处理,但当我执行命令php app/console swiftmailer:spool:send时,消息会从假脱机中删除,但不会发送,控制台中的输出是:发送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');
}   

问题是使用smtp而不是邮件,我的正确配置文件是:

swiftmailer:
    transport:            mail
    username:             ~
    password:             ~

这不是你的邮件被假脱机的原因。这与smtp的配置方式有关。