Created
September 2, 2022 12:43
-
-
Save patrickposner/81a148b28dde8cbd611197cf3919b9ac to your computer and use it in GitHub Desktop.
Send Mail from Webhook with plain PHP
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 | |
// Check if the webhook should be fired. | |
if ( ! isset( $_GET['mailme'] ) ) { | |
return; | |
} | |
// Check if there is POST request. | |
if ( empty( $_POST ) ) { | |
return; | |
} | |
// iterate over $_POST request and build message. | |
$message = ''; | |
foreach ( $_POST as $key => $value ) { | |
$message .= '<p><b>' . htmlspecialchars( $key ) . '</b>: ' . htmlspecialchars( $value ) . '<p>' . PHP_EOL; | |
} | |
// Send mail with PHP. | |
mail("contact@mywebsite.com","A new submission", $message ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment