Last active
October 14, 2016 14:31
-
-
Save Murazaki/616f845f65ee203fa9f6aae98f8ea525 to your computer and use it in GitHub Desktop.
Simple Send Mail PHP from POST variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$to = isset($_POST["to"])? $_POST["to"] : ''; // '[email protected]'; | |
$subject = isset($_POST["subject"])? $_POST["subject"] : ''; // 'le sujet'; | |
$message = isset($_POST["message"])? $_POST["message"] : ''; // 'Bonjour !'; | |
$headers = 'From: '.( isset($_POST["from"])? $_POST["from"] : '') .'\r\n' . // 'From: [email protected]' . "\r\n" . | |
'X-Mailer: PHP/' . phpversion(); | |
echo mail($to, $subject, $message, $headers); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$_POST = json_decode(file_get_contents('php://input'), true); | |
$to = isset($_POST["to"])? $_POST["to"] : ''; // '[email protected]'; | |
$subject = isset($_POST["subject"])? $_POST["subject"] : ''; // 'le sujet'; | |
$message = isset($_POST["message"])? $_POST["message"] : ''; // 'Bonjour !'; | |
$headers = 'From: '.( isset($_POST["from"])? $_POST["from"] : '') .'\r\n' . // 'From: [email protected]' . "\r\n" . | |
'X-Mailer: PHP/' . phpversion(); | |
echo mail($to, $subject, $message, $headers); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment