SMTP

模拟 451 Local Error 响应

The requested action was aborted due to a local error in processing. The server encountered an internal issue that prevented it from completing the command.

查看完整参考 →

1 HTTP 响应

HTTP 响应
HTTP/1.1 451 Local Error
Content-Type: application/json
Date: Tue, 25 Feb 2026 12:00:00 GMT
Content-Length: 50

{
  "error": "local_error",
  "message": "Local Error"
}

2 使用 curl 测试

terminal
curl -i https://httpbin.org/status/451

3 在您的框架中返回 451 Local Error

django
from django.http import JsonResponse


def my_view(request):
    return JsonResponse(
        {"error": "local_error", "message": "Local Error"},
        status=451,
    )
flask
from flask import Flask, jsonify

app = Flask(__name__)


@app.route("/endpoint")
def my_endpoint():
    return jsonify({"error": "local_error", "message": "Local Error"}), 451
fastapi
from fastapi import FastAPI
from fastapi.responses import JSONResponse

app = FastAPI()


@app.get("/endpoint")
def my_endpoint():
    return JSONResponse(
        content={"error": "local_error", "message": "Local Error"},
        status_code=451,
    )
express.js
// Express.js
app.get('/endpoint', (req, res) => {
  res.status(451).json({"error": "local_error", "message": "Local Error"});
});
spring boot
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

@RestController
public class MyController {

    @GetMapping("/endpoint")
    public ResponseEntity<Map<String, Object>> myEndpoint() {
        return ResponseEntity
            .status(451)
            .body(Map.of("error", "local_error",
                         "message", "Local Error"));
    }
}
go net/http
package main

import (
    "encoding/json"
    "net/http"
)

func myHandler(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "application/json")
    w.WriteHeader(451)
    json.NewEncoder(w).Encode(map[string]string{
        "error":   "local_error",
        "message": "Local Error",
    })
}
ruby on rails
class MyController < ApplicationController
  def my_action
    render json: {"error": "local_error", "message": "Local Error"},
           status: :local_error
  end
end
asp.net core
// ASP.NET Core Minimal API
app.MapGet("/endpoint", () =>
    Results.Json(
        new { error = "local_error", message = "Local Error" },
        statusCode: 451
    )
);

更多 SMTP 模拟页面