mailgun-php/test.php

54 lines
1.9 KiB
PHP
Raw Normal View History

2013-07-19 05:09:13 +04:00
<?php
//require 'vendor/autoload.php';
2013-07-20 04:00:07 +04:00
2013-07-18 09:48:12 +04:00
require_once('Mailgun/autoload.php');
require('Mailgun/Common/Message.php');
require('Mailgun/Common/BatchMessage.php');
2013-07-18 09:48:12 +04:00
use Mailgun\Common;
use Mailgun\Exceptions\NoDomainsConfigured;
use Mailgun\Exceptions\HTTPError;
$client = new Common\Client("key-ca6d168e492611df8307001d60d24a9c-0b27e", "aawdawdad.ninomail.com", true);
2013-07-20 04:00:07 +04:00
$message = new Mailgun\Common\Message(array('from' =>"travis@aawdawdad.ninomail.com", 'to' => "travis@tswientek.com", "subject" => "subject here", "text" => "hello"));
2013-07-19 05:09:13 +04:00
$response = $client->sendMessage($message->getMessage());
echo $response->getBody();
2013-07-19 05:09:13 +04:00
//$message = new Mailgun\Common\Message($client);
/*
$message = new Mailgun\Common\BatchMessage($client, true);
2013-07-19 05:09:13 +04:00
2013-07-20 04:00:07 +04:00
$message->setFromAddress("travis@tswientek.com", "From Name");
$message->setSubject("%recipient.first%, This is the subject of the message!");
$message->setTextBody("%recipient.first%, This is the text body of the message!");
$message->setHtmlBody("%recipient.first%, %recipient.my.id% This is the html body of the message!");
2013-07-20 04:00:07 +04:00
$message->addAttachment("@GitHub_Logo.png");
$message->addAttachment("@batman-logo-big.gif");
2013-07-20 04:00:07 +04:00
$message->setTestMode("yes");
$message->setDkim("yes");
//$message->setDeliveryTime("January 15, 2014 8:00AM", "CST");
2013-07-20 04:00:07 +04:00
$message->setOpenTracking("yes");
$message->setClickTracking("yes");
$message->addCustomOption("o:myoption", "true");
$message->addCampaignId("askldf");
$message->addCustomData("mycustomdata", array("name"=> "travis"));
2013-07-20 04:00:07 +04:00
//echo $message->sendMessage();
//$message->addBatchRecipient("travis@tswientek.com", array("first" => "Travis", "last" => "Swientek", "my.id" => "ABC12345"));
for($i = 0; $i<5; $i++){
$message->addBatchRecipient("travis@".$i."test.com", array("first" => "$i - First", "last" => "$i - Last", "my.id" => "ABC12345"));
}
$message->endBatchMessage();
//echo $client->sendMessage($message->getMessage())->getBody();
*/
?>