@@ -94,15 +94,7 @@ public function addAuthenticator(AuthenticatorInterface $authenticator): void
9494
9595 protected function doHeloCommand (): void
9696 {
97- try {
98- $ response = $ this ->executeCommand (sprintf ("EHLO %s \r\n" , $ this ->getLocalDomain ()), [250 ]);
99- } catch (TransportExceptionInterface $ e ) {
100- parent ::doHeloCommand ();
101-
102- return ;
103- }
104-
105- $ capabilities = $ this ->getCapabilities ($ response );
97+ $ capabilities = $ this ->callHeloCommand ();
10698
10799 /** @var SocketStream $stream */
108100 $ stream = $ this ->getStream ();
@@ -116,25 +108,30 @@ protected function doHeloCommand(): void
116108 throw new TransportException ('Unable to connect with STARTTLS. ' );
117109 }
118110
119- try {
120- $ response = $ this ->executeCommand (sprintf ("EHLO %s \r\n" , $ this ->getLocalDomain ()), [250 ]);
121- $ capabilities = $ this ->getCapabilities ($ response );
122- } catch (TransportExceptionInterface $ e ) {
123- parent ::doHeloCommand ();
124-
125- return ;
126- }
111+ $ capabilities = $ this ->callHeloCommand ();
127112 }
128113
129114 if (\array_key_exists ('AUTH ' , $ capabilities )) {
130115 $ this ->handleAuth ($ capabilities ['AUTH ' ]);
131116 }
132117 }
133118
134- private function getCapabilities ( string $ ehloResponse ): array
119+ private function callHeloCommand ( ): array
135120 {
121+ try {
122+ $ response = $ this ->executeCommand (sprintf ("EHLO %s \r\n" , $ this ->getLocalDomain ()), [250 ]);
123+ } catch (TransportExceptionInterface $ e ) {
124+ try {
125+ parent ::doHeloCommand ();
126+ } catch (TransportExceptionInterface $ ex ) {
127+ if (!$ ex ->getCode ()) {
128+ throw $ e ;
129+ }
130+ }
131+ }
132+
136133 $ capabilities = [];
137- $ lines = explode ("\r\n" , trim ($ ehloResponse ));
134+ $ lines = explode ("\r\n" , trim ($ response ));
138135 array_shift ($ lines );
139136 foreach ($ lines as $ line ) {
140137 if (preg_match ('/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di ' , $ line , $ matches )) {
0 commit comments