Skip to content

Commit 51c6385

Browse files
author
Bernhard Breytenbach
committed
Add example of how to send a verify email message
1 parent adefe35 commit 51c6385

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

examples/verify-create-email.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use MessageBird\Client;
4+
use MessageBird\Exceptions\AuthenticateException;
5+
use MessageBird\Exceptions\BalanceException;
6+
use MessageBird\Objects\Verify;
7+
8+
require_once(__DIR__ . '/../autoload.php');
9+
10+
$messageBird = new Client('YOUR_ACCESS_KEY'); // Set your own API access key here.
11+
12+
$verify = new Verify();
13+
$verify->recipient = 'Client Name <client-email@example.com>';
14+
15+
$extraOptions = [
16+
'type' => 'email',
17+
'originator' => 'Email Verification <verify@company.com>',
18+
'timeout' => 60,
19+
];
20+
21+
try {
22+
$verifyResult = $messageBird->verify->create($verify, $extraOptions);
23+
var_dump($verifyResult);
24+
} catch (AuthenticateException $e) {
25+
// That means that your accessKey is unknown
26+
echo 'wrong login';
27+
} catch (BalanceException $e) {
28+
// That means that you are out of credits, so do something about it.
29+
echo 'no balance';
30+
} catch (\Exception $e) {
31+
echo $e->getMessage();
32+
}

0 commit comments

Comments
 (0)