27 lines
774 B
PHP
27 lines
774 B
PHP
|
<?php
|
||
|
|
||
|
// Fetch the raw POST body containing the message
|
||
|
$postBody = file_get_contents('php://input');
|
||
|
|
||
|
// JSON decode the body to an array of message data
|
||
|
$message = json_decode($postBody, true);
|
||
|
if ($message) {
|
||
|
// Do something with the data
|
||
|
// echo $message['Message'];
|
||
|
if ($message['Type'] == "SubscriptionConfirmation") {
|
||
|
echo "Now needs to reply to " . $message['SubscribeURL'];
|
||
|
} else {
|
||
|
$to = "sns@racker.pro";
|
||
|
$subject = "SNS alert from AWS";
|
||
|
$headers = "From: sns@racker.pro\r\n";
|
||
|
$headers .= "MIME-Version: 1.0\r\n";
|
||
|
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
|
||
|
|
||
|
if (mail($to, $subject, $message['Message'], $headers)) {
|
||
|
echo 'Your message has been sent.';
|
||
|
} else {
|
||
|
echo 'There was a problem sending the email.';
|
||
|
}
|
||
|
}
|
||
|
}
|