function test_marshal2() { $message = new SimpleMessage\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($this->getSample("sample_attachment.txt")); $expected = file_get_contents($this->getSample("sample_RichTextAttachment.txt")); $expected = str_replace("\n", "\r\n", $expected); $cleanups = ["!boundary=\"\\w+\"!i" => "boundary=\"SHA1-HASH\"", "!--\\w+!i" => "--SHA1-HASH"]; $marshaled = preg_replace(array_keys($cleanups), array_values($cleanups), $message->marshal()); // drop($expected, $marshaled); $this->assertEquals($expected, $marshaled, "random/unique sha1s are difficult to test against."); }
<?php require "vendor/autoload.php"; /** * RichText Raw Message */ $message = new SimpleMessage\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 SimpleMessage\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);