Skip to content

Commit d622cb4

Browse files
committed
Added options to disable ssl verify_peer_name to avoid issues on some shared hosting installations
1 parent ed5d4ca commit d622cb4

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

system/mail/mail.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@ public function send() {
129129
ini_set('sendmail_from', $this->option['from']);
130130
$subject = '=?UTF-8?B?' . base64_encode($this->option['subject']) . '?=';
131131

132-
mail($to, $subject, $message, $header, $this->option['parameter'] ?? '');
132+
\mail($to, $subject, $message, $header, $this->option['parameter'] ?? '');
133133
}
134134
}

system/mail/smtp.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727
namespace Vvveb\System\Mail;
2828

2929
class Smtp {
30+
protected $socketOptions = [
31+
'ssl' => [
32+
'allow_self_signed' => true,
33+
'verify_peer' => false,
34+
'verify_peer_name' => false,
35+
//'ciphers' => 'TLSv1.3|TLSv1.2|TLSv1|SSLv3',
36+
//'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT,
37+
//'crypto_type' => STREAM_CRYPTO_METHOD_TLS_CLIENT,
38+
],
39+
];
40+
3041
protected $option = [
3142
'port' => 25,
3243
'timeout' => 5,
@@ -132,7 +143,14 @@ public function send() {
132143
$hostname = $this->option['host'];
133144
}
134145

135-
$handle = fsockopen($hostname, $this->option['port'], $errno, $errstr, $this->option['timeout']);
146+
//$handle = fsockopen($hostname, $this->option['port'], $errno, $errstr, $this->option['timeout']);
147+
$context = stream_context_create();
148+
149+
if ($this->socketOptions) {
150+
stream_context_set_options($context, $this->socketOptions);
151+
}
152+
153+
$handle = stream_socket_client("tcp://$hostname:{$this->option['port']}", $errno, $errstr, $this->option['timeout'], STREAM_CLIENT_CONNECT, $context);
136154

137155
if ($handle) {
138156
if (substr(PHP_OS, 0, 3) != 'WIN') {

0 commit comments

Comments
 (0)