Created
November 2, 2019 13:53
-
-
Save nickfox-taterli/68b1050f149c8eefb764034b2e0d28a9 to your computer and use it in GitHub Desktop.
testmail.app PHP example
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 | |
$graphql = '{ | |
inbox(namespace: "prefix" tag:"") { | |
result message count emails { | |
id | |
namespace | |
tag | |
timestamp | |
envelope_from | |
envelope_to | |
from from_parsed { | |
address name | |
} | |
to to_parsed { | |
address name | |
} | |
cc cc_parsed { | |
address name | |
} | |
subject | |
headers { | |
key line | |
} | |
date | |
messageId | |
references | |
html | |
text | |
attachments{ | |
filename | |
contentType | |
checksum | |
size | |
headers{ | |
key line | |
} | |
downloadUrl | |
contentId | |
cid | |
related | |
} | |
SPF | |
dkim | |
spam_score | |
spam_report | |
sender_ip | |
downloadUrl | |
} | |
} | |
}'; | |
$postfile = json_encode(array('query' => $graphql)); | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, 'https://api.testmail.app/api/graphql'); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfile); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Authorization: Bearer xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx","Content-Type: application/json")); | |
$response = curl_exec($curl); | |
$err = curl_error($curl); | |
curl_close($curl); | |
if ($err) { | |
echo "cURL Error #:" . $err; | |
} else { | |
$result = json_decode($response,true)['data']['inbox']; | |
var_dump($result); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment