-
Notifications
You must be signed in to change notification settings - Fork 0
/
subscribe.php
43 lines (38 loc) · 1.18 KB
/
subscribe.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$email = $_POST['email'];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mail-sender-api1.p.rapidapi.com/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sendto' => 'EMAIL_HERE',
'name' => 'GPT USER',
'replyTo' => $email,
'ishtml' => 'false',
'title' => 'Newsletter Subscription',
'body' => $email . 'Subscribed to our newsletter!'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-rapidapi-host: mail-sender-api1.p.rapidapi.com",
"x-rapidapi-key: REMEMBER TO REGISTER FOR SERVICE"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
} else {
echo "Invalid request method.";
}
?>