示例#1
0
<?php

require_once "vendor/autoload.php";
FUnit::test("SESMessage -- create full message", function () {
    $message = new \Gaggle\SESMessage();
    $message->setFrom("*****@*****.**");
    $message->setTo(["*****@*****.**", "*****@*****.**"]);
    $message->setCc(["*****@*****.**"]);
    $message->setCc(["*****@*****.**"], true);
    $message->setBcc(["*****@*****.**"]);
    $message->setReplyTo(["*****@*****.**"]);
    $message->setReturnPath("*****@*****.**");
    $message->setSubject("THIS IS A SUBJECT");
    $message->setMessage("<strong>OMG!</strong> It's like, <b>WOAH!</b> For real, I'm kinda <i>freaking</i> out right now.");
    $expected = array("Source" => "*****@*****.**", "Destination" => array("ToAddresses" => ["*****@*****.**", "*****@*****.**"], "CcAddresses" => ["*****@*****.**", "*****@*****.**"], "BccAddresses" => ["*****@*****.**"]), "Message" => array("Subject" => array("Data" => "THIS IS A SUBJECT", "Charset" => "UTF-8"), "Body" => array('Html' => array("Data" => "<strong>OMG!</strong> It's like, <b>WOAH!</b> For real, I'm kinda <i>freaking</i> out right now.", "Charset" => "UTF-8"), 'Text' => array("Data" => "OMG! It's like, WOAH! For real, I'm kinda freaking out right now.", "Charset" => "UTF-8"))), "ReplyToAddresses" => ["*****@*****.**"], "ReturnPath" => "*****@*****.**");
    FUnit::equal($expected, $message->marshal());
});
FUnit::test("SESMessage -- create partial message", function () {
    $message = new \Gaggle\SESMessage();
    $message->setFrom("*****@*****.**");
    $message->setTo(["*****@*****.**", "*****@*****.**"]);
    // $message->setCc(["*****@*****.**"]);
    // $message->setCc(["*****@*****.**"], true);
    // $message->setBcc(["*****@*****.**"]);
    // $message->setReplyTo(["*****@*****.**"]);
    // $message->setReturnPath("*****@*****.**");
    $message->setSubject("THIS IS A SUBJECT");
    $message->setMessage("<strong>OMG!</strong> It's like, <b>WOAH!</b> For real, I'm kinda <i>freaking</i> out right now.");
    $expected = array("Source" => "*****@*****.**", "Destination" => array("ToAddresses" => ["*****@*****.**", "*****@*****.**"]), "Message" => array("Subject" => array("Data" => "THIS IS A SUBJECT", "Charset" => "UTF-8"), "Body" => array('Html' => array("Data" => "<strong>OMG!</strong> It's like, <b>WOAH!</b> For real, I'm kinda <i>freaking</i> out right now.", "Charset" => "UTF-8"), 'Text' => array("Data" => "OMG! It's like, WOAH! For real, I'm kinda freaking out right now.", "Charset" => "UTF-8"))));
    FUnit::equal($expected, $message->marshal());
});
示例#2
0
<?php

require "vendor/autoload.php";
/**
 * RichText Raw Message
 */
$message = new Gaggle\RichMessage();
$message->setHeaders(["from" => "*****@*****.**", "to" => "*****@*****.**", "subject" => "this should be rich text w/ an attachment"]);
$message->setMessage("this is some <strong>html</strong> text.");
$message->attachFile("./examples/attachment.txt");
print_r($message->marshal());
/**
 * AWS SES Message
 */
$config = array("access_key" => "", "secret_key" => "", "region" => "");
//overwrite our examples
if (file_exists("conf/config.ini")) {
    $config = parse_ini_file("conf/config.ini");
}
use Aws\Common\Aws;
// Instantiate an S3 client
$aws = Aws::factory(array("key" => $config["access_key"], "secret" => $config["secret_key"], "region" => $config["region"]));
$ses = $aws->get('ses');
$message = new Gaggle\SESMessage();
// this is NOT a valid, verified email addess
$message->setHeaders(["from" => "*****@*****.**", "to" => "*****@*****.**", "subject" => "this should be rich text w/ an attachment"]);
$message->setMessage("this is some <strong>html</strong> text.");
$response = $ses->sendEmail($message->marshal());
print_r($response);