function sendHTMLEmail($email, $judul, $isi, $isiHTML)
 {
     $mj = new Mailjet();
     $apikey = $mj->apiKey;
     $apisecret = $mj->secretKey;
     $mj = new \Mailjet\Client($apikey, $apisecret);
     $body = ['FromEmail' => $this->fromEmail, 'FromName' => $this->fromName, 'Subject' => $judul, 'Text-part' => $isi, 'Html-part' => $isiHTML, 'Recipients' => [['Email' => $email]]];
     $response = $mj->post(Resources::$Email, ['body' => $body]);
     return $response;
     //        $body = [
     //            'FromEmail' => "*****@*****.**",
     //            'FromName' => "Mailjet Pilot",
     //            'Subject' => "Your email flight plan!",
     //            'Text-part' => "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
     //            'Html-part' => "<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!",
     //            'Recipients' => [
     //                [
     //                    'Email' => "*****@*****.**"
     //                ]
     //            ]
     //        ];
     //        $response = $mj->post(Resources::$Email, ['body' => $body]);
     //        $response->success() && var_dump($response->getData());
 }
Example #2
0
 public function testPost()
 {
     $client = new \Mailjet\Client('', '', false);
     $email = ['FromName' => 'Mailjet PHP test', 'FromEmail' => '*****@*****.**', 'Text-Part' => 'Simple Email test', 'Subject' => 'PHPunit', 'Html-Part' => '<h3>Simple Email Test</h3>', 'Recipients' => [['Email' => '*****@*****.**']], 'MJ-custom-ID' => 'Hello ID'];
     $ret = $client->post(Resources::$Email, ['body' => $email]);
     $this->assertUrl('/send', $ret);
     $this->assertPayload($email, $ret);
 }
<?php

require_once "vendor/autoload.php";
require_once "conf.php";
use Mailjet\Resources;
$html_part = file_get_contents("electronic_ticket/template.html");
$mj = new \Mailjet\Client($API_KEY, $API_SECRET_KEY);
$params = array("method" => "POST", "FromEmail" => $sender, "FromName" => "Mailjet Pilot", "Subject" => 'Your ticket to {{var:destination}}', "MJ-TemplateLanguage" => true, "Html-part" => $html_part, "Vars" => array("author" => "Emmanuel", "url" => "http://www.example.com", "question" => "How to create a notification system for questions?", "questiondetail" => "I would like to do a nice notification system", "answer" => "Use this example", "comment" => "Just commenting for fun", "view" => 1, "vote" => 2), "Recipients" => array(array("Email" => $recipients[0], "Vars" => array("firstclass" => true, "chaufferedcar" => true, "business" => false, "destination" => 'London')), array("Email" => $recipients[1], "Vars" => array("firstclass" => true, "chaufferedcar" => false, "business" => false, "destination" => 'Paris')), array("Email" => $recipients[2], "Vars" => array("firstclass" => false, "chaufferedcar" => false, "business" => false, "destination" => 'London')), array("Email" => $recipients[3], "Vars" => array("firstclass" => true, "chaufferedcar" => true, "business" => false, "destination" => 'New York')), array("Email" => $recipients[4], "Vars" => array("firstclass" => true, "chaufferedcar" => true, "business" => false, "destination" => 'London'))));
$response = $mj->post(Resources::$Email, ['body' => $params]);
var_dump($response->request->getUrl());
var_dump($response->request->getFilters());
var_dump($response->request->getBody());
$response->success() && var_dump($response->getData());
?>

<?php

require 'vendor/autoload.php';
use Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('000eba343b93950ace9fc511163eb48a'), getenv('157f543c70a9faac5b600f798cae4207'));
$body = ['ContactsLists' => [['ListID' => "{$ListID_1}", 'Action' => "addnoforce"]]];
$response = $mj->post(Resources::$ContactManagecontactslists, ['id' => $id, 'body' => $body]);
$response->success() && var_dump($response->getData());
Example #5
0
<?php

require 'vendor/autoload.php';
use Mailjet\Resources;
$apikey = '0a153a3f3b56db3c769d725d7fa37d98';
$apisecret = 'f035b40be80e4149c3b0e336cbbce6fc';
$mj = new \Mailjet\Client(getenv($apikey), getenv($apisecret));
$body = ['FromEmail' => "*****@*****.**", 'FromName' => "Mailjet Pilot", 'Subject' => "Your email flight plan!", 'Text-part' => "Dear passenger, welcome to Mailjet! May the delivery force be with you!", 'Html-part' => "<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!", 'Recipients' => [['Email' => "*****@*****.**"]]];
$response = $mj->post(Resources::$Email, ['body' => $body]);