@@ -94,15 +94,7 @@ public function addAuthenticator(AuthenticatorInterface $authenticator): void
94
94
95
95
protected function doHeloCommand (): void
96
96
{
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 ();
106
98
107
99
/** @var SocketStream $stream */
108
100
$ stream = $ this ->getStream ();
@@ -116,25 +108,30 @@ protected function doHeloCommand(): void
116
108
throw new TransportException ('Unable to connect with STARTTLS. ' );
117
109
}
118
110
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 ();
127
112
}
128
113
129
114
if (\array_key_exists ('AUTH ' , $ capabilities )) {
130
115
$ this ->handleAuth ($ capabilities ['AUTH ' ]);
131
116
}
132
117
}
133
118
134
- private function getCapabilities ( string $ ehloResponse ): array
119
+ private function callHeloCommand ( ): array
135
120
{
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
+
136
133
$ capabilities = [];
137
- $ lines = explode ("\r\n" , trim ($ ehloResponse ));
134
+ $ lines = explode ("\r\n" , trim ($ response ));
138
135
array_shift ($ lines );
139
136
foreach ($ lines as $ line ) {
140
137
if (preg_match ('/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di ' , $ line , $ matches )) {
0 commit comments