mortensen/smtp-resend-monitor 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mortensen/smtp-resend-monitor

最新稳定版本:v1.0.5

Composer 安装命令:

composer require mortensen/smtp-resend-monitor

包简介

WordPress mu-plugin that monitors SMTP failures and sends alerts via Resend HTTP API.

README 文档

README

WordPress mu-plugin that monitors SMTP failures and sends alerts via Resend HTTP API.

The Problem

When SMTP fails on a WordPress site, there is no way to be notified — because the notification mechanism (email) is itself broken. Sites can go months with broken SMTP until someone reports that forms aren't working.

How It Works

  1. Real-time detection: Hooks into wp_mail_failed to catch SMTP failures as they happen
  2. Proactive health-check: Sends a test email every 24 hours via WP-Cron — if it fails, you get an alert
  3. Alert via HTTP: Bypasses the broken SMTP entirely by sending alerts through Resend's HTTP API
  4. Cooldown: Maximum 1 alert per 6 hours per site to prevent spam

Works with any SMTP setup: WP Mail SMTP plugin, roots/acorn-mail, or native WordPress.

Requirements

  • PHP >= 8.0
  • WordPress
  • A Resend account with a verified domain

Installation

composer require mortensen/smtp-resend-monitor

The package type is wordpress-muplugin, so Composer places it automatically in mu-plugins/.

Configuration

Add these variables to your .env file (Bedrock) or define them in wp-config.php:

Variable Required Description
SMTP_MONITOR_RESEND_API_KEY Yes Your Resend API key
SMTP_MONITOR_ALERT_TO Yes Alert recipient email
SMTP_MONITOR_ALERT_FROM Yes Alert sender email (must be from a verified Resend domain)

Bedrock (.env)

SMTP_MONITOR_RESEND_API_KEY=re_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SMTP_MONITOR_ALERT_TO=dev@mortensen.cat
SMTP_MONITOR_ALERT_FROM=no-reply@mortensen.cat

wp-config.php

define('SMTP_MONITOR_RESEND_API_KEY', 're_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
define('SMTP_MONITOR_ALERT_TO', 'dev@mortensen.cat');
define('SMTP_MONITOR_ALERT_FROM', 'no-reply@mortensen.cat');

How It Detects Failures

Real-time (wp_mail_failed)

Every time wp_mail() fails, WordPress fires the wp_mail_failed action with a WP_Error object. This plugin hooks into it and sends an alert via Resend's HTTP API.

Health-check (WP-Cron)

Every 24 hours, the plugin sends a test email via wp_mail() to the site's admin email. If the send fails, it triggers an alert. This catches silent failures where no user activity triggers wp_mail().

Alert Email

You receive an email with:

  • Site name and URL
  • Error message from WordPress
  • Detection type: "Real-time" or "Health-check"
  • Timestamp

Cooldown

To prevent alert spam (e.g., a form being submitted repeatedly while SMTP is broken), only 1 alert is sent per 6 hours per site.

Behavior When Not Configured

If SMTP_MONITOR_RESEND_API_KEY is not set, the plugin does nothing — no errors, no warnings, no performance impact.

License

MIT

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固