[英]Symfony2 SwiftMailer doesn't send
I have a Linux server with SMTP relay configured. 我有一台配置了SMTP中继的Linux服务器。 Using the command "mail test@test.com" it works but when I use SwiftMailerBundle, no mail is sent.
使用命令“ mail test@test.com”可以工作,但是当我使用SwiftMailerBundle时,不会发送任何邮件。
Logs : 日志:
[2014-03-14 10:01:06] event.DEBUG: Notified event "console.command" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand". [] []
[2014-03-14 10:01:06] event.DEBUG: Notified event "console.terminate" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onTerminate". [] []
[2014-03-14 10:01:06] event.DEBUG: Notified event "console.terminate" to listener "Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onTerminate". [] []
Parameters.yml : Parameters.yml:
mailer_transport: mail
mailer_host: localhost
mailer_user: myusername
mailer_password: ********
My command : 我的命令:
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class AbsenceCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('absence:absence')
->setDescription('Envoi des absences aux parents')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('noreply@test.com')
->setTo('mymail@test.com')
->setBody("Test")
;
$this->getContainer()->get('mailer')->send($message);
$mailer = $this->getContainer()->get('mailer');
$transport = $mailer->getTransport();
if ($transport instanceof \Swift_Transport_SpoolTransport) {
$spool = $transport->getSpool();
$sent = $spool->flushQueue($this->getContainer()->get('swiftmailer.transport.real'));
}
$output->writeln("E-mail envoyé aux parents des apprentis !");
}
}
Do you have any idea on the solution ? 您对解决方案有什么想法吗?
Regards ! 问候 !
try to install postfix mail server. 尝试安装后缀邮件服务器。 use this command to install postfix:sudo apt-get install postfix
使用此命令安装postfix:sudo apt-get install postfix
I believe it's because of the mailer_transport: parameter value. 我相信是因为mailer_transport:参数值。 try setting it to mailer_transport: smtp .
尝试将其设置为mailer_transport:smtp 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.