今日、私はContent-Security-Policy(CSP)を実装しました。また、 POSTリクエストをreport-uriに送信するように含めました。MDNがWebサイトで説明しているように、POSTリクエストは次のようになります。myserver.com/csp-report.php
{
  "csp-report": {
    "document-uri": "http://example.com/signup.html",
    "referrer": "http://evil.example.net/haxor.html",
    "blocked-uri": "http://evil.example.net/injected.png",
    "violated-directive": "img-src *.example.com",
    "original-policy": "default-src 'self'; img-src 'self' *.example.com; report-uri /_/csp-reports",
  }
}
この情報をreports@myserver.comに電子メールで送信したいと思います。現在、私はこのコードを持っていますが、それは単に「Array()Array()」に電子メールを送ります
<?php
$tars = Array("reports@myserver.com", "webm@myserver.com");
$from = "notify@myserver.com";
$subject = "CSP Report";
$text = print_r($_POST, true);
$text = (isSet($_GET["text"]) ? $_GET["text"] : $text);
foreach($tars as $tar){
    $e = mail($tar,$subject,$text,"From: $from");
}
if($e){
    header("Content-type: text/javascript"); 
    echo 'console.log("Email Sent");';
    exit();
}
?>