-
Notifications
You must be signed in to change notification settings - Fork 0
/
verification.php
64 lines (54 loc) · 2.09 KB
/
verification.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
<?php
require_once './vendor/autoload.php';
use Templateless\Content;
use Templateless\Email;
use Templateless\EmailAddress;
use Templateless\Templateless;
use Templateless\Collection;
use Templateless\Theme;
use Templateless\Components\SocialItem;
use Templateless\Components\Service;
try {
$api_key = $env["TEMPLATELESS_API_KEY"] ?? getenv("TEMPLATELESS_API_KEY");
if (!isset($api_key) || $api_key == '') {
echo "Set TEMPLATELESS_API_KEY to your Templateless API key";
exit;
}
$email_address = $env["TEMPLATELESS_EMAIL_ADDRESS"] ?? getenv("TEMPLATELESS_EMAIL_ADDRESS");
if (!isset($email_address) || $email_address == '') {
echo "Set TEMPLATELESS_EMAIL_ADDRESS to your own email address";
exit;
}
$header = Collection::builder()
->image('https://templateless.net/myco.webp', null, 100, null, 'MyCo')
->build();
$footer = Collection::builder()
->text("If you did not sign up for a MyCo account, please ignore this email.\nThis link will expire in 24 hours.")
->socials([
new SocialItem(Service::TWITTER, 'MyCo'),
new SocialItem(Service::GITHUB, 'MyCo'),
])
->link('Unsubscribe', 'https://example.com')
->build();
$verify_email_link = 'https://example.com/verify?token=ABC';
$content = Content::builder()
->theme(Theme::SIMPLE)
->header($header)
->text("Hi there,")
->text("Welcome to **MyCo**! We're excited to have you on board. Before we get started, we need to verify your email address.")
->text("Please confirm your email by clicking the button below:")
->button("Verify Email", $verify_email_link)
->text("Or use the link below:")
->link($verify_email_link, $verify_email_link)
->footer($footer)
->build();
$email = Email::builder()
->to(new EmailAddress($email_address))
->subject("Confirm your email")
->content($content)
->build();
$templateless = new Templateless($api_key);
$templateless->send($email);
} catch (\Exception $e) {
echo $e;
}