send.php 749 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. ini_set('display_errors', 1);
  3. ini_set('display_startup_errors', 1);
  4. error_reporting(E_ALL);
  5. date_default_timezone_set('Europe/Warsaw');
  6. $address = 'adam.pioterek+website@protonmail.ch';
  7. $subject = date(DATE_ATOM);
  8. $json = file_get_contents('php://input');
  9. $data = json_decode($json, true);
  10. if (!isset($data['email'])) {
  11. http_response_code(400);
  12. echo 'msg not given';
  13. die();
  14. }
  15. $msg = $data['email'];
  16. if (preg_match("@^-----BEGIN PGP MESSAGE-----[\r\n]+Version: OpenPGP.js v3.0.11[\r\n]+Comment: https://openpgpjs.org[A-Za-z0-9+/=\r\n]+-----END PGP MESSAGE-----[\r\n]*$@", $msg) !== 1) {
  17. http_response_code(400);
  18. echo 'not encrypted';
  19. die();
  20. }
  21. $msg = wordwrap($msg, 70, " \r\n");
  22. mail($address, $subject, $msg);
  23. ?>