· 5 years ago · Sep 16, 2020, 09:02 PM
1<?php
2
3$variable = array();
4$variable['name'] = 'Ihsan Mukhlis';
5$template = file_get_contents('dailypanel-verification.html');
6foreach ($variable as $key => $value) {
7 $template = str_replace('{{' . $key . '}}', $value, $template);
8}
9
10$api_token = 'f12d1b496ff20342bdcfcdac00020c44'; //silahkan copy dari api token mailketing
11$from_name = 'No Reply Daily Panel'; //nama pengirim
12$from_email = 'noreply@daily-panel.net'; //email pengirim
13$subject = 'Verifikasi Email'; //judul email
14$content = $template; //isi email format text / html
15$recipient = 'ihsanmklsbusiness@gmail.com'; //penerima email
16$params = [
17 'from_name' => $from_name,
18 'from_email' => $from_email,
19 'recipient' => $recipient,
20 'subject' => $subject,
21 'content' => $content,
22 'api_token' => $api_token
23];
24$ch = curl_init();
25curl_setopt($ch, CURLOPT_URL, "https://app.mailketing.co.id/api/v1/send");
26curl_setopt($ch, CURLOPT_POST, true);
27curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
28curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
29$output = curl_exec($ch);
30print_r($output);
31curl_close($ch);
32$parse = json_decode($output, true);
33if ($parse['status'] == 'success') {
34 print('Success!');
35} else {
36 print('Failed!');
37}
38