{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/32148","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/32148/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/32148/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/32148/events","html_url":"https://github.com/symfony/symfony/issues/32148","id":459799450,"node_id":"MDU6SXNzdWU0NTk3OTk0NTA=","number":32148,"title":"[Mailer] Delivery randomly fails with Google SMTP Relay","user":{"login":"bpolaszek","id":5569077,"node_id":"MDQ6VXNlcjU1NjkwNzc=","avatar_url":"https://avatars0.githubusercontent.com/u/5569077?v=4","gravatar_id":"","url":"https://api.github.com/users/bpolaszek","html_url":"https://github.com/bpolaszek","followers_url":"https://api.github.com/users/bpolaszek/followers","following_url":"https://api.github.com/users/bpolaszek/following{/other_user}","gists_url":"https://api.github.com/users/bpolaszek/gists{/gist_id}","starred_url":"https://api.github.com/users/bpolaszek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpolaszek/subscriptions","organizations_url":"https://api.github.com/users/bpolaszek/orgs","repos_url":"https://api.github.com/users/bpolaszek/repos","events_url":"https://api.github.com/users/bpolaszek/events{/privacy}","received_events_url":"https://api.github.com/users/bpolaszek/received_events","type":"User","site_admin":false},"labels":[{"id":100079,"node_id":"MDU6TGFiZWwxMDAwNzk=","url":"https://api.github.com/repos/symfony/symfony/labels/Bug","name":"Bug","color":"e10c02","default":false},{"id":1302422644,"node_id":"MDU6TGFiZWwxMzAyNDIyNjQ0","url":"https://api.github.com/repos/symfony/symfony/labels/Mailer","name":"Mailer","color":"DDDDDD","default":false},{"id":237003792,"node_id":"MDU6TGFiZWwyMzcwMDM3OTI=","url":"https://api.github.com/repos/symfony/symfony/labels/Status:%20Needs%20Review","name":"Status: Needs Review","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2019-06-24T09:57:08Z","updated_at":"2019-08-03T07:32:06Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hello there,\r\n\r\n## TL;DR:\r\nUsing _Google SMTP Relay_ with the new _Mailer Component_ works in a random manner.\r\n\r\n-----\r\n\r\n### Background\r\nI'm working on a new project for which I chose the new _Mailer component_ over _Swift Mailer_ with the same configuration of what I'm used to (i.e. using [Google SMTP Relay](https://support.google.com/a/answer/2956491)).\r\n\r\nThis service accessible from Google Apps allows using Google's SMTP servers **without authentication**, on an IP whitelist basis. \r\n\r\nThe Google SMTP Relay DSN is the following one, and doesn't require any credentials:\r\n\r\n```bash\r\nsmtp://smtp-relay.gmail.com:587?encryption=&auth_mode=\r\n```\r\n\r\n### Issue\r\nI've been using it with SwiftMailer for years without any issue, but when using _Symfony Mailer_, it is _likely_ to result in the following exception:\r\n\r\n> {\"exception\":\"[object] (Symfony\\Component\\Mailer\\Exception\\TransportException(code: 0): Expected response code \"250\" but got an empty response. at ~/builds/prod/releases/4/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php:236)\",\"command\":\"app:test\",\"message\":\"Expected response code \"250\" but got an empty response.\"}\r\n\r\nThe _likely_ is the problem, because that exception doesn't occur every time.\r\n\r\nWhen adding a `dump($response);` after this line: \r\nhttps://github.com/symfony/symfony/blob/aa4385dc125213342c8292c9060693fa51cbad4d/src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php#L142 \r\n\r\nThere's a 3/5 chance the dumped response will be \r\n\r\n```bash\r\n\"421 4.7.0 Try again later, closing connection. (EHLO) x12sm193387wrq.21 - gsmtp\\r\\n\"\r\n\"\"\r\n````\r\n\r\nover\r\n\r\n```bash\r\n\"\"\"\r\n250-smtp-relay.gmail.com at your service, [92.154.***.***]\\r\\n\r\n250-SIZE 157286400\\r\\n\r\n250-8BITMIME\\r\\n\r\n250-STARTTLS\\r\\n\r\n250-ENHANCEDSTATUSCODES\\r\\n\r\n250-PIPELINING\\r\\n\r\n250-CHUNKING\\r\\n\r\n250 SMTPUTF8\\r\\n\r\n\"\"\"\r\n\"250 2.1.0 OK f50sm190172eda.33 - gsmtp\\r\\n\"\r\n\"250 2.1.5 OK f50sm190172eda.33 - gsmtp\\r\\n\"\r\n\"354  Go ahead f50sm190172eda.33 - gsmtp\\r\\n\"\r\n\"250 2.0.0 OK  1561367145 f50sm190172eda.33 - gsmtp\\r\\n\"\r\n```\r\n\r\nYou'll probably tell me the problem comes from Google, since it's a `421` response code from their servers. The problem is that the issue just _never_ occurs with  _SwiftMailer_. Does the new component does some more things (like some sort of handshaking or whatever - I have no knowledge of how this works) Google SMTP servers can't interpret properly?\r\n\r\n### How to reproduce\r\nWhen I run the following command several times:\r\n\r\n```bash\r\n# .env\r\n###> symfony/mailer ###\r\nMAILER_DSN=smtp://smtp-relay.gmail.com:587?encryption=&auth_mode=\r\n###< symfony/mailer ###\r\n###> symfony/swiftmailer-bundle ###\r\nMAILER_URL=smtp://smtp-relay.gmail.com:587?encryption=&auth_mode=\r\n###< symfony/swiftmailer-bundle ###\r\n```\r\n\r\n```php\r\nnamespace App\\Command;\r\n\r\nuse Symfony\\Component\\Console\\Command\\Command;\r\nuse Symfony\\Component\\Console\\Input\\InputInterface;\r\nuse Symfony\\Component\\Console\\Output\\OutputInterface;\r\nuse Symfony\\Component\\Console\\Style\\SymfonyStyle;\r\nuse Symfony\\Component\\Mailer\\Exception\\TransportExceptionInterface;\r\nuse Symfony\\Component\\Mailer\\MailerInterface as SymfonyMailer;\r\nuse Symfony\\Component\\Mime\\Email as SymfonyMailerEmail;\r\nuse Symfony\\Component\\Mime\\Part\\TextPart;\r\n\r\nclass TestCommand extends Command\r\n{\r\n    protected static $defaultName = 'app:test';\r\n\r\n    /**\r\n     * @var SymfonyMailer\r\n     */\r\n    private $symfonyMailer;\r\n    \r\n    /**\r\n     * @var \\Swift_Mailer\r\n     */\r\n    private $swiftMailer;\r\n\r\n    public function __construct(SymfonyMailer $symfonyMailer, \\Swift_Mailer $swiftMailer)\r\n    {\r\n        parent::__construct();\r\n        $this->symfonyMailer = $symfonyMailer;\r\n        $this->swiftMailer = $swiftMailer;\r\n    }\r\n\r\n    protected function execute(InputInterface $input, OutputInterface $output)\r\n    {\r\n\r\n        $io = new SymfonyStyle($input, $output);\r\n\r\n        try {\r\n            $io->comment('Sending through Symfony Mailer...');\r\n            $message = new SymfonyMailerEmail();\r\n            $message->setBody(new TextPart(\\date(('Y-m-d H:i:s'))));\r\n            $message->subject('Symfony Mailer');\r\n            $message->addFrom('helloworld@mycustomdomain.com');\r\n            $message->addTo('me@mycustomdomain.com');\r\n            $this->symfonyMailer->send($message);\r\n            $io->success('Done.');\r\n        } catch (TransportExceptionInterface $e) {\r\n            $io->error($e->getMessage());\r\n        }\r\n\r\n        try {\r\n            $io->comment('Sending throught Swift Mailer...');\r\n            $message = new \\Swift_Message('Swift Mailer', \\date(('Y-m-d H:i:s')));\r\n            $message->addFrom('helloworld@mycustomdomain.com');\r\n            $message->addTo('me@mycustomdomain.com');\r\n            $this->swiftMailer->send($message);\r\n            $io->success('Done.');\r\n        } catch (\\Exception $e) {\r\n            $io->error($e->getMessage());\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nSwiftMailer _always_ succeeds, while the Mailer component succeeds _sometimes_.\r\n\r\nThank you,\r\nBen"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/517902861","html_url":"https://github.com/symfony/symfony/issues/32148#issuecomment-517902861","issue_url":"https://api.github.com/repos/symfony/symfony/issues/32148","id":517902861,"node_id":"MDEyOklzc3VlQ29tbWVudDUxNzkwMjg2MQ==","user":{"login":"tienvx","id":3327643,"node_id":"MDQ6VXNlcjMzMjc2NDM=","avatar_url":"https://avatars2.githubusercontent.com/u/3327643?v=4","gravatar_id":"","url":"https://api.github.com/users/tienvx","html_url":"https://github.com/tienvx","followers_url":"https://api.github.com/users/tienvx/followers","following_url":"https://api.github.com/users/tienvx/following{/other_user}","gists_url":"https://api.github.com/users/tienvx/gists{/gist_id}","starred_url":"https://api.github.com/users/tienvx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tienvx/subscriptions","organizations_url":"https://api.github.com/users/tienvx/orgs","repos_url":"https://api.github.com/users/tienvx/repos","events_url":"https://api.github.com/users/tienvx/events{/privacy}","received_events_url":"https://api.github.com/users/tienvx/received_events","type":"User","site_admin":false},"created_at":"2019-08-03T07:32:06Z","updated_at":"2019-08-03T07:32:06Z","author_association":"NONE","body":"Let me try to create a reproduce project.\r\n\r\nLink to the project: TBD"}}
{"actor":{"display_login":"tienvx"}}