Files
dnsmgr/app/lib/mail/Sendcloud.php
T
wmwlwmwl ff8cb42e2d fix: 移除废弃的 curl_close() 调用,兼容 PHP 8.5 (#498)
- 删除 18 个文件中共 32 处 curl_close() 调用(PHP 8.0+ 已为无操作)

- 修复 ACMEv2.php 中 $code 可能为 null 的潜在问题

- 调整 public/.htaccess 伪静态规则,兼容 Windows + CGI 模式
2026-06-28 18:13:20 +08:00

42 lines
1.1 KiB
PHP

<?php
namespace app\lib\mail;
class Sendcloud
{
private $apiUser;
private $apiKey;
public function __construct($apiUser, $apiKey)
{
$this->apiUser = $apiUser;
$this->apiKey = $apiKey;
}
public function send($to, $sub, $msg, $from, $from_name)
{
if (empty($this->apiUser) || empty($this->apiKey)) return false;
$url = 'http://api.sendcloud.net/apiv2/mail/send';
$data = array(
'apiUser' => $this->apiUser,
'apiKey' => $this->apiKey,
'from' => $from,
'fromName' => $from_name,
'to' => $to,
'subject' => $sub,
'html' => $msg
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$json = curl_exec($ch);
$arr = json_decode($json, true);
if ($arr['statusCode'] == 200) {
return true;
} else {
return implode("\n", $arr['message']);
}
}
}