-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
88 lines (74 loc) · 2.29 KB
/
example.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
require __DIR__ . '/vendor/autoload.php';
use EmailEnginePhp\EmailEngine;
$ee = new EmailEngine(array(
"access_token" => "3eb50ef80efb67885afb43844df8ae01e4eecb99c4defac3aa37ec5b8b4f1339",
"service_secret" => "a23da152f5b88543f52420a0de0e0eb6",
"ee_base_url" => "http://127.0.0.1:3000/",
"redirect_url" => "http://127.0.0.1:5000/handler.php",
));
echo $ee->get_authentication_url(array("account" => null));
echo "\n";
$ee->set_webhook_settings(array(
"enabled" => true,
"url" => "http://127.0.0.1:5000/webhooks.php",
"events" => array("*"),
"headers" => array("Received", "List-ID"),
"text" => 1024 * 1024,
));
print_r($ee->get_webhook_settings());
$server_stats = $ee->request('get', '/v1/stats');
print_r($server_stats);
// Register a new account
$account_response = $ee->request('post', '/v1/account', array(
'account' => null, // autogenerated by EmailEngine
'name' => 'Andris Reinman',
'email' => '[email protected]',
'imap' => array(
'auth' => array(
'user' => 'andris',
'pass' => 'secretvalue',
),
'host' => 'turvaline.ekiri.ee',
'port' => 993,
'secure' => true,
),
'smtp' => array(
'auth' => array(
'user' => 'andris',
'pass' => 'secretvalue',
),
'host' => 'turvaline.ekiri.ee',
'port' => 465,
'secure' => true,
),
));
$account_id = $account_response['account'];
$account_connected = false;
while (!$account_connected) {
sleep(1);
$account_info = $ee->request('get', "/v1/account/$account_id");
if ($account_info["state"] == "connected") {
$account_connected = true;
echo "Account $account_id is connected\n";
} else {
echo "Account $account_id is ${account_info['state']}...\n";
}
}
// send an email using this account
$submit_response = $ee->request('post', "/v1/account/$account_id/submit", array(
"from" => array(
"name" => "Andris Reinman",
"address" => "[email protected]",
),
"to" => array(
array(
"name" => "Ethereal",
"address" => "[email protected]",
))
,
"subject" => "Test message",
"text" => "Hello from myself!",
"html" => "<p>Hello from myself!</p>",
));
print_r($submit_response);