In Akeneo 2.1.8, I'm trying to send an e-mail in a console aware container like so:
$mailer = $this->getContainer()->get('mailer');
$message = $mailer->createMessage();
// generate message
$mailer->send($message);
However, it does not look like that the Akeneo configuration is used in this way. For example: my SMTP server runs at localhost:1025
, but when I start debugging this code, it appears that localhost:25
is used.
Am I missing something here? How can I use the mailer in a console command, while still using the Akeneo configuration?
I got the answer to my own question. @Gaël, I already tried adding the configuration settings to my parameters.yml
file:
parameters:
mailer_transport: smtp
mailer_host: localhost
mailer_port: 1025
mailer_user: ~
mailer_password: ~
But what I didn't do was add the port to the config.yml
file:
swiftmailer:
port: "%mailer_port%"
The weird part is: if I look at the original source code this line is there, but in my project this line was missing for reasons unknown. Fixed the config.yml
-file and now everything works as expected.