diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-26 04:43:12 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-26 04:43:12 +0300 |
| commit | 9cb35f2bf2127cc8ac077aae17514a57e576217d (patch) | |
| tree | bf809e73dded8e481d0a2e16c488831052016313 /tests/service | |
| parent | b594effb847b86fc6b1dae49d7948c46bba35e58 (diff) | |
| download | classroom-9cb35f2bf2127cc8ac077aae17514a57e576217d.tar.gz classroom-9cb35f2bf2127cc8ac077aae17514a57e576217d.tar.bz2 classroom-9cb35f2bf2127cc8ac077aae17514a57e576217d.zip | |
alfa.2 version; seceral optimizations; added support for mail-relay
Diffstat (limited to 'tests/service')
| -rw-r--r-- | tests/service/mailjet.php | 56 |
1 files changed, 56 insertions, 0 deletions
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 @@ +<?php + +$envelope = [ + 'email' => 'piipiis@gmail.com', + 'name' => 'Test User', + 'subject' => 'Some Subject', + 'body' => "Ευχαριστούμε,<br> + για την εγγραφή σας στο <b>Classroom</b>.<br> + <br> + <i>Καλή συνέχεια!</i>." +]; + + +$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 '<pre>'; + print_r($response); + echo "\n\nstatus: ". $response->Messages[0]->Status; + if ($response->Messages[0]->Status == 'success') echo "\n\nSuccess = true"; +echo '</pre>';
\ No newline at end of file |
