Reputation: 31
I just started to use Swiftmailer with Symfony 3 and it is sending e-mail fine, but when I insert a configuration error on purpose, like changing the name of the server for a faulty one, I don't get any errors from the "send" method. The code follows:
$message = new \Swift_Message('Teste SICOS');
$message->setFrom(['[email protected]' => 'SICOS'])
->setTo('[email protected]')
->setBody("teste");
$res = $this->get("mailer")->send($message, $failures);
if (!$res){
$msg = "houve um erro no envio do e-mail. ".$failures;
} else {
$msg = "E-mail enviado.";
}
dump($failures);
In the config.yml I use:
swiftmailer:
host: xxxx.xxxx.xxxx.xxx
port: 25
spool: { type: memory }
Both when I use the correct server configuration and the wrong one, the result of the send
method $res
is 1
, which, I think, means, the e-mail has been sent. But the profiler does show the following error:
Exception occurred while flushing email queue: Connection could not be established with host xxxx [php_network_getaddresses: getaddrinfo failed: Este host n�o � conhecido. #0]
Why doesn't the send method return an error and how can I get it to return one, so I can show a message to the users saying something went wrong?
Upvotes: 1
Views: 456
Reputation: 31
It seems that problem was with the configuration
spool: { type: memory }
With this on, the e-mail is not sent right away, but it's saved for sending later.
Upvotes: 1