Sending email to Symfony through the docker container mail server

I am trying to send email through a docker container in my symfony app in dev environment.

I have the following file for the dock:

my-app-mailer:
  image: tvial/docker-mailserver
  container_name: my_app_mailer
  hostname: mail
  domainname: myapp.dev
  ports:
  - "25:25"
  - "143:143"
  - "587:587"
  - "993:993"
  volumes:
  - ./mail/spamassassin:/tmp/spamassassin/
  - ./mail/postfix:/tmp/postfix/

So, when I start docker build, my container is well started and I see its logs.

I followed the reconnaissance of the official tvial / docker-mailserver repo

https://hub.docker.com/r/tvial/docker-mailserver/

In my .yml options, I have these options

parameters:
    ...
    mailer_transport: smtp
    mailer_host: mail.myapp.dev
    mailer_user: user1@myapp.dev
    mailer_password: user1pass
    ...

But when I send emails through swiftmailer, I do not see any of them :(

I pointed the delivery_address parameter to mine (so that every mail in dev env is sent to my address).

However, I managed to send mail via telnet:

telnet mail.myapp.dev smtp

And I see the mail arriving.

Does anyone know what I haven't seen?

EDIT

php- ( )

$mailer = $this->getContainer()->get('mailer');
$message = new \Swift_Message('subject', 'body');
$message
    ->setFrom('user1@myapp.dev')
    ->setTo('xxxx@xxx.xx')
;

$mailer->send($message);

EDIT 2

: :

php app/console swiftmailer:email:send --from=test@myapp.dev --to=xxx@xxx.xx --subject=s1 --body=b1

:\

+4
1

, , . - symfony. exit() , eventListener, , .

exit() ( ), .

+3

All Articles