In my dev enviroment I want to use mailhog to catch the emails. I've installed and configure my php.ini to sustitute the sendmail property. If in command line i run this
php -r "mail(......);"
the mail gets captured by mailhog. The problem is with Symfony and Swiftmailer. To make a test i created a very simple controller with this:
/**
* @return Response
*/
public function homeAction() : Response
{
mail('some@mail.com', 'tasest', 'aaaa');
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send@example.com')
->setTo('recipient@example.com')
->setBody(
'aaaaa',
'text/html'
);
$this->get('mailer')->send($message);
return $this->render('::base.html.twig');
}
Now, the email sent by the mail function gets captured by mailhog. But not the mail sent by SwiftMailer.
In my config_dev I have this:
# Swiftmailer Configuration
swiftmailer:
transport: "sendmail"
which I think should be enough.
Am I missing something here?
P.S.: If i use a real address (instead of recipient@example.com) the email gets sent and received
Update: I also tried to configure mailhog for smtp, parameters.yml:
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_port: 1025
mailer_user: null
mailer_password: null
config.yml:
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
port: "%mailer_port%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
But the result was the same result.