php表单提交发邮件/微信

2026-02-28/技术/lz1473 OLEOU/
简单的HTML表单 + PHP脚本,用 PushPlus 推送消息到微信。这个方案不需要复杂配置,只需要你有 PushPlus 的 Token。

演示

演示1  演示2

代码

HTML表单查看源文件复制就行
新建send.php,代码如下
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $title = trim($_POST['title'] ?? '');
    $content = trim($_POST['content'] ?? '');

    if(!$title || !$content){
        echo json_encode(['code'=>0,'msg'=>'标题或内容不能为空']);
        exit;
    }

    // ⚠️ 你的 PushPlus Token
    $token = "你的PushPlusToken";

    // PushPlus 邮件推送和微信推送一样,只是通过你注册的邮箱接收
    $data = [
        "token" => $token,
        "title" => $title,
        "content" => $content,
        "template" => "html"  // html 或 text
        // "channel" => "mail" // 如果你想强制走邮件通道可以加这个参数
    ];

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://www.pushplus.plus/send");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($ch);
    curl_close($ch);

    echo $response; // 返回结果给前端
} else {
    echo json_encode(['code'=>0,'msg'=>'非法请求']);
}
?>
评论列表
正在加载评论…
邮箱
验证码