This commit is contained in:
wangjinlei
2024-08-12 15:51:30 +08:00
parent 1f7220f36e
commit 0a6126543b
6 changed files with 73 additions and 53 deletions

View File

@@ -278,6 +278,52 @@ function search_array_val($arr, $val)
}
}
function sendMyEmail($email,$title,$content){
$mail = new PHPMailer(true);
try {
// 服务器设置
$mail->isSMTP();
$mail->Host = 'smtp.tmrjournals.com.cn'; // SMTP 服务器
$mail->SMTPAuth = true;
$mail->Username = 'wangjinlei@tmrjournals.com.cn'; // SMTP 用户名
$mail->Password = '123456qwe';
// $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable STARTTLS encryption
// $mail->Port = 587; // TCP port for STARTTLS
// $mail->SMTPDebug = 2; // Enable debugging for detailed output
// $mail->SMTPSecure = ''; // 不使用 SSL 或 TLS
// $mail->Port = 25;
$mail->SMTPSecure = false; // 禁用TLS/SSL加密
$mail->SMTPAutoTLS = false; // 禁用自动TLS加密
$mail->Port = 25; // 非加密的SMTP通常使用端口25
// 收件人设置
$mail->setFrom('wangjinlei@tmrjournals.com.cn', 'tmr');
$mail->addAddress($email, $email); // 添加一个收件人
$mail->addReplyTo('wangjinlei@tmrjournals.com.cn', 'repack');
// 附件(可选)
// $mail->addAttachment('/var/tmp/file.tar.gz');
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg');
// 内容
$mail->isHTML(true); // 设置邮件格式为 HTML
$mail->Subject = $title;
$pre = Env::get('emailtemplete.pre');
$net = Env::get('emailtemplete.net');
$net = str_replace("{{email}}", 'wangjinlei@tmrjournals.com.cn', $net);
$bo = $pre.$content.$net;
$mail->Body = $bo;
$mail->AltBody = $content;
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
}
function GptChar($message,$ckey)
{
$url = 'https://api.openai.com/v1/chat/completions';