I
I
Igor2019-11-16 00:07:16
symfony
Igor, 2019-11-16 00:07:16

How to properly configure symfony/mailer?

Colleagues, hello!
I'm trying to use Sending Emails with Mailer
Everything that needs to be configured, configured.
The only thing I can't figure out is how to properly configure
Transport


Emails are delivered via a "transport". And without installing anything else, you can deliver emails over smtp by configuring your .env file:

Question to this line, can I specify here, for example, the login and password from the yandex mail service?
# .env
MAILER_DSN=smtp://user:[email protected]

I tried to set it up like this
# .env
MAILER_DSN=smtp://login:[email protected]

Trying to send
docker exec -ti cc.app php bin/secure messenger:consume -vv

Tons of bugs
PS D:\OpenServer\OSPanel\domains\сhinese-catalog> docker exec -ti cc.app php bin/secure messenger:consume -vv


 [OK] Consuming messages from transports "async".


 // The worker will automatically exit once it has received a stop signal via the messenger:stop-workers command.

 // Quit the worker with CONTROL-C.

2019-11-15T21:05:55+00:00 [info] Received message Symfony\Component\Mailer\Messenger\SendEmailMessage
2019-11-15T21:05:55+00:00 [error] Error thrown while handling message Symfony\Component\Mailer\Messenger\SendEmailMessage. Dispatching for retry #1 using 1000 ms delay. Error: "Expected response code "250" but got an empty response."
2019-11-15T21:05:55+00:00 [info] Sending message Symfony\Component\Mailer\Messenger\SendEmailMessage with Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransport
2019-11-15T21:05:56+00:00 [info] Received message Symfony\Component\Mailer\Messenger\SendEmailMessage
2019-11-15T21:05:56+00:00 [error] Error thrown while handling message Symfony\Component\Mailer\Messenger\SendEmailMessage. Dispatching for retry #3 using 4000 ms delay. Error: "Expected response code "250" but got an empty response."
2019-11-15T21:05:56+00:00 [info] Sending message Symfony\Component\Mailer\Messenger\SendEmailMessage with Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransport
2019-11-15T21:05:57+00:00 [info] Received message Symfony\Component\Mailer\Messenger\SendEmailMessage
2019-11-15T21:05:57+00:00 [error] Error thrown while handling message Symfony\Component\Mailer\Messenger\SendEmailMessage. Dispatching for retry #1 using 1000 ms delay. Error: "Expected response code "250" but got an empty response."
2019-11-15T21:05:57+00:00 [info] Sending message Symfony\Component\Mailer\Messenger\SendEmailMessage with Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransport
2019-11-15T21:05:57+00:00 [info] Received message Symfony\Component\Mailer\Messenger\SendEmailMessage
2019-11-15T21:05:57+00:00 [error] Error thrown while handling message Symfony\Component\Mailer\Messenger\SendEmailMessage. Dispatching for retry #2 using 2000 ms delay. Error: "Connection to "tcp://smtp.yandex.ru:25" has been closed unexpectedly."
2019-11-15T21:05:57+00:00 [info] Sending message Symfony\Component\Mailer\Messenger\SendEmailMessage with Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransport
2019-11-15T21:05:58+00:00 [info] Received message Symfony\Component\Mailer\Messenger\SendEmailMessage
2019-11-15T21:05:58+00:00 [error] Error thrown while handling message Symfony\Component\Mailer\Messenger\SendEmailMessage. Dispatching for retry #2 using 2000 ms delay. Error: "Expected response code "250" but got an empty response."
2019-11-15T21:05:58+00:00 [info] Sending message Symfony\Component\Mailer\Messenger\SendEmailMessage with Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransport
2019-11-15T21:05:59+00:00 [info] Received message Symfony\Component\Mailer\Messenger\SendEmailMessage
2019-11-15T21:06:00+00:00 [error] Error thrown while handling message Symfony\Component\Mailer\Messenger\SendEmailMessage. Dispatching for retry #3 using 4000 ms delay. Error: "Expected response code "250" but got an empty response."
2019-11-15T21:06:00+00:00 [info] Sending message Symfony\Component\Mailer\Messenger\SendEmailMessage with Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransport
2019-11-15T21:06:00+00:00 [info] Received message Symfony\Component\Mailer\Messenger\SendEmailMessage
2019-11-15T21:06:01+00:00 [critical] Error thrown while handling message Symfony\Component\Mailer\Messenger\SendEmailMessage. Removing from transport after 3 retries. Error: "Expected response code "250" but got an empty response."
2019-11-15T21:06:01+00:00 [info] Received message Symfony\Component\Mailer\Messenger\SendEmailMessage
2019-11-15T21:06:01+00:00 [error] Error thrown while handling message Symfony\Component\Mailer\Messenger\SendEmailMessage. Dispatching for retry #3 using 4000 ms delay. Error: "Expected response code "250" but got an empty response."
2019-11-15T21:06:01+00:00 [info] Sending message Symfony\Component\Mailer\Messenger\SendEmailMessage with Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransport

How to configure correctly?
# .env
MAILER_DSN=smtp://login:[email protected]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OnYourLips, 2019-11-16
@OnYourLips

Sending mail is not easy.
You need to set up a local server so that sending does not take much time. Inside the local server, you set up relayhost from some provider.
Here is an example: https://docs.aws.amazon.com/en_us/ses/latest/Devel...
If you are not setting up a local one, then you need to look for a third-party service that will send emails. And you send letters through it via the HTTPS protocol, preferably from a separate worker, so as not to increase the page creation time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question