Symfony / SwiftMailer /无法在没有假脱机的情况下发送电子邮件

时间:2017-02-17 09:47:59

标签: symfony swiftmailer

我遇到电子邮件发送问题。没有假脱机我无法发送电子邮件。 在文档中,我只看到$mailer->send(); http://symfony.com/doc/current/email.html

但对我来说,它什么都不做。 要发送电子邮件,我必须这样做:

            $mailer->send($message);
            $spool = $mailer->getTransport()->getSpool();
            $transport = $this->get('swiftmailer.transport.real');
            $spool->flushQueue($transport);

ContactType.php

    $builder
        ->add('name', TextType::class, [
            'required' => false
        ])
        ->add('email', EmailType::class)
        ->add('message', TextareaType::class);

哪里可能有问题?

1 个答案:

答案 0 :(得分:1)

您可以定义一个非假脱机邮件并使用它而不是默认邮件:

https://symfony.com/doc/current/reference/configuration/swiftmailer.html#using-multiple-mailers