Last active
November 1, 2024 17:56
-
-
Save ShiponKarmakar/c344e6889858870bf4ee03f91c8cc7cf to your computer and use it in GitHub Desktop.
PHP Scripts
This file contains 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 | |
// Naming Constant | |
define( "RECIPIENT_NAME", "John Doe" ); | |
define( "RECIPIENT_EMAIL", "[email protected]" ); | |
// Values | |
$success = false; | |
$senderName = isset( $_POST['username'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['username'] ) : ""; | |
$senderEmail = isset( $_POST['email'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['email'] ) : ""; | |
$subject = isset( $_POST['subject'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['subject'] ) : ""; | |
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", | |
$_POST['message'] ) : ""; | |
// Send the email | |
if ( $senderName && $senderEmail && $message ) { | |
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">"; | |
$headers = "From: " . $senderName . " <" . $senderEmail . ">"; | |
$success = mail( $recipient, $subject, $message, $headers ); | |
//Set Location | |
header('Location: index.html'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment