wusheng233喵喵ICP备案+酱酱窝存档记录


源代码: Assets-helpers.php

<?php

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

/**
 * Summary of searchArray
 * @param mixed $array
 * @param mixed $value
 * @return array
 */
function searchArray($array, $value)
{
    $results = [];
    foreach ($array as $key => $item) {
        if ($item === $value) {
            $results[] = $array;
        } else if (is_array($item)) {
            $subResults = searchArray($item, $value);
            if (!empty($subResults)) {
                $results = array_merge($results, $subResults);
            }
        }
    }
    return $results;
}

/**
 * 发送邮件
 *
 * @param string $addAddress 收件人邮箱地址
 * @param string $subject 邮件主题
 * @param string $body 邮件内容
 * @param string $altBody 邮件的纯文本内容(可选)
 * @return bool 成功返回 true,失败返回 false
 */
function sendMail($addAddress, $subject, $body, $altBody = "")
{
    $mail = new PHPMailer(true);

    try {
        // Server settings
        $mail->CharSet = 'UTF-8';                        // Set email encoding to UTF-8
        $mail->isSMTP();                                 // Use SMTP
        $mail->Host = 'mail.gov.moe';                    // SMTP server
        $mail->SMTPAuth = true;                          // Enable SMTP authentication
        $mail->Username = 'nya@love.ml';                 // SMTP username
        $mail->Password = 'wuminke2010618';              // SMTP password or authorization code
        $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // Enable TLS or SSL encryption
        $mail->Port = 465;                               // TCP port to connect to

        // Recipients
        $mail->setFrom('nya@love.ml', '喵喵ICP备案');      // Set sender's email and name
        $mail->addAddress($addAddress);                   // Add recipient
        $mail->addReplyTo('nya@love.ml', 'Info');         // Set reply-to address

        // Content
        $mail->isHTML(true);                              // Set email format to HTML
        $mail->Subject = $subject;                        // Email subject
        $mail->Body = $body;                              // HTML email body
        $mail->AltBody = $altBody ?: strip_tags($body);   // Optional plain-text body, fallback to stripped HTML

        $mail->send();
        return true;
    } catch (Exception $e) {
        // Log the error message or take appropriate action
        error_log("邮件发送失败: {$mail->ErrorInfo}");
        return false;
    }
}
这个网站由wusheng233制作,生成了静态页面