1818use SMF \Lang ;
1919use SMF \MailAgent \MailAgent ;
2020use SMF \MailAgent \MailAgentInterface ;
21+ use SMF \Sapi ;
2122use SMF \Url ;
22- use SMF \Utils ;
2323
2424/**
2525 * Sends mail via SMTP
@@ -41,11 +41,12 @@ class SMTP extends MailAgent implements MailAgentInterface
4141 public bool $ useTLS = false ;
4242
4343 /**
44- * @var resource
44+ * @var resource|false
4545 *
4646 * A file pointer containing the active connection to the SMTP server.
47+ * PHP does not have a type hint for resource of type Stream. So we just use mixed.
4748 */
48- private object $ socket ;
49+ private mixed $ socket ;
4950
5051 /**
5152 * {@inheritDoc}
@@ -111,16 +112,9 @@ public function connect(): bool
111112 return false ;
112113 }
113114
114- // Enable the encryption
115- // php 5.6+ fix
116- $ crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT ;
115+ $ crypto_method = STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
117116
118- if (defined ('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT ' )) {
119- $ crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
120- $ crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
121- }
122-
123- if (!@stream_socket_enable_crypto ($ this ->socket , true , $ crypto_method )) {
117+ if (!stream_socket_enable_crypto ($ this ->socket , true , $ crypto_method )) {
124118 return false ;
125119 }
126120
@@ -198,8 +192,8 @@ public function send(string $to, string $subject, string $message, string $heade
198192 }
199193
200194 // Almost done, almost done... don't stop me just yet!
201- Utils:: sapiSetTimeLimit (300 );
202- Utils:: sapiResetTimeout ();
195+ Sapi:: setTimeLimit (300 );
196+ Sapi:: resetTimeout ();
203197
204198 return true ;
205199 }
0 commit comments