From 059e0d95d0c28bc5060e87e146eaf7411f51bf90 Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Thu, 27 Apr 2023 03:47:30 +0300 Subject: skeleton commit; based on an anom project --- tests/service/mailjet.php | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/service/mailjet.php (limited to 'tests/service/mailjet.php') diff --git a/tests/service/mailjet.php b/tests/service/mailjet.php new file mode 100644 index 0000000..8e97715 --- /dev/null +++ b/tests/service/mailjet.php @@ -0,0 +1,56 @@ + 'piipiis@gmail.com', + 'name' => 'Test User', + 'subject' => 'Some Subject', + 'body' => "Ευχαριστούμε,
+ για την εγγραφή σας στο Classroom.
+
+ Καλή συνέχεια!." +]; + + +$body = [ + 'Messages' => [ + [ + 'From' => [ + 'Email' => REPLY_TO_EMAIL, + 'Name' => MAIL_FROM_NAME + ], + 'To' => [ + [ + 'Email' => $envelope['email'], + 'Name' => $envelope['name'] + ] + ], + 'Subject' => $envelope['subject'], + 'HTMLPart' => $envelope['body'] + ] + ] +]; + +$ch = curl_init(); + +curl_setopt($ch, CURLOPT_URL, "https://api.mailjet.com/v3.1/send"); +curl_setopt($ch, CURLOPT_POST, 1); +curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json') +); +curl_setopt( + $ch, + CURLOPT_USERPWD, + MAIL_PASSWORD +); +$server_output = curl_exec($ch); +curl_close ($ch); + +$response = json_decode($server_output); + +echo '
';
+    print_r($response);
+    echo "\n\nstatus: ". $response->Messages[0]->Status;
+    if ($response->Messages[0]->Status == 'success') echo "\n\nSuccess = true";
+echo '
'; \ No newline at end of file -- cgit v1.2.3