Skip to content
Snippets Groups Projects
Commit 12d8b47c authored by Kevin Abel's avatar Kevin Abel
Browse files

Add an example script for message generation and sending.

parent 9f1ec6dd
No related branches found
No related tags found
No related merge requests found
<?php
if (PHP_SAPI != "cli") {
exit;
}
require_once dirname(__FILE__).'/../../config.sample.php';
// COMPOSE MESSAGE
$smallHead = 'font-size: 16px; line-height: 24px; font-family: Georgia, serif; color: #4a3b13; padding-bottom: 0px !important;';
$smallBold = 'font-size: 16px; line-height: 24px; font-family: Georgia, serif; font-weight: bold;';
$mailer = new UNL_WDN_Emailer_Main();
$mailer->html_header = 'UNL Marketplace';
$mailer->main_uri = 'http://marketplace.unl.edu/';
$mailer->html_footer = <<<EOD
Unless otherwise noted, items sold by a unit or department of the University of Nebraska-Lincoln, under the management of UNL Marketplace, are subject to sales and use taxes in the state of Nebraska in accordance with the applicable laws of the state. Learn more about the UNL Marketplace university service.<br>
<br>
420 Nebraska Hall, P.O. Box 880525, Lincoln, NE 68588-0525, USA | 402-472-9964
EOD;
$child = new UNL_WDN_Emailer_Template_Band();
$child->headline = 'Hello Example Person,';
$innerChild = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild->body = 'Thank you for shopping with us. We\'d like to let you know that we have received your order, and are preparing it for shipment. Once your package ships we will send an email with a link to track your order. If you would like to view the status of your order, please visit ';
$link = new UNL_WDN_Emailer_Template_Link();
$link->href = 'http://www.unl.edu/';
$link->label = 'Check Order Status';
$innerChild->addChild($link);
$innerChild->addText(' on ');
$link = new UNL_WDN_Emailer_Template_Link();
$link->href = 'http://marketplace.unl.edu/';
$link->label = 'UNL Marketplace';
$innerChild->addChild($link);
$innerChild->addText('. If you have any questions about your order please contact us at support@example.com or call us at (402) 472-9964 Monday - Friday, 9am - 5pm CST.');
$child->addChild($innerChild);
$mailer->addChild($child);
$child = new UNL_WDN_Emailer_Template_Band();
$child->background = '#E7E2D6';
$child->headlineColor = '#cc0000';
$child->headline = 'Order Confirmation';
$innerChild = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild->body = 'Order #1000000023' . "\n" . 'Placed on July 6, 2010';
$child->addChild($innerChild);
$innerChild = new UNL_WDN_Emailer_Template_Halves();
$innerChild3 = new UNL_WDN_Emailer_Template_TextList();
$innerChild->addChild($innerChild3, 'left');
$innerChild2 = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild2->cssClass = 'padding';
$innerChild2->cssStyles = $smallHead;
$innerChild2->includeDefaultStyles = false;
$innerChild2->body = 'Your order is billed to:';
$innerChild3->addChild($innerChild2);
$innerChild2 = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild2->cssClass = 'padding';
$innerChild2->cssStyles = $smallBold;
$innerChild2->includeDefaultStyles = false;
$innerChild2->body = <<<EOD
Example Person
1400 R St
Lincoln, NE 68508
United States
T: 402-555-5555
EOD;
$innerChild3->addChild($innerChild2);
$innerChild3 = new UNL_WDN_Emailer_Template_TextList();
$innerChild->addChild($innerChild3, 'right');
$innerChild2 = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild2->cssClass = 'padding';
$innerChild2->cssStyles = $smallHead;
$innerChild2->includeDefaultStyles = false;
$innerChild2->body = 'Your chosen payment method:';
$innerChild3->addChild($innerChild2);
$innerChild2 = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild2->cssClass = 'padding';
$innerChild2->cssStyles = $smallBold;
$innerChild2->includeDefaultStyles = false;
$innerChild2->body = <<<EOD
Credit Card
Visa xxxx-1111
EOD;
$innerChild3->addChild($innerChild2);
$innerChild2 = new UNL_WDN_Emailer_Template_InnerWrapper();
$innerChild2->addChild($innerChild);
$child->addChild($innerChild2);
$innerChild = new UNL_WDN_Emailer_Template_Callout();
$innerChild2 = new UNL_WDN_Emailer_Template_Halves();
$innerChild2->includeWrapper = false;
$innerChild->addChild($innerChild2);
$innerChild3 = new UNL_WDN_Emailer_Template_InnerWrapper();
$innerChild3->addChild($innerChild);
$child->addChild($innerChild3);
$innerChild = new UNL_WDN_Emailer_Template_TextList();
$innerChild2->addChild($innerChild, 'left');
$innerChild3 = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild3->cssClass = 'padding';
$innerChild3->cssStyles = $smallHead;
$innerChild3->includeDefaultStyles = false;
$innerChild3->body = 'Your shipping service:';
$innerChild->addChild($innerChild3);
$innerChild3 = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild3->cssClass = 'padding';
$innerChild3->includeDefaultStyles = false;
$innerChild3->cssStyles = $smallBold;
$innerChild3->body = 'UPS - UPS Ground';
$innerChild->addChild($innerChild3);
$innerChild = new UNL_WDN_Emailer_Template_TextList();
$innerChild2->addChild($innerChild, 'right');
$innerChild3 = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild3->cssClass = 'padding';
$innerChild3->cssStyles = $smallHead;
$innerChild3->includeDefaultStyles = false;
$innerChild3->body = 'Your order will be sent to:';
$innerChild->addChild($innerChild3);
$innerChild3 = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild3->cssClass = 'padding';
$innerChild3->cssStyles = $smallBold;
$innerChild3->includeDefaultStyles = false;
$innerChild3->body = <<<EOD
Example Person
1400 R St
Lincoln, NE 68508
United States
T: 402-555-5555
EOD;
$innerChild->addChild($innerChild3);
$innerChild = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild2 = new UNL_WDN_Emailer_Template_Custom();
$innerChild->addChild($innerChild2);
$child->addChild($innerChild);
$innerChild2->body = <<<EOD
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tbody>
<tr>
<td align="left" valign="top" style="font-size: 17px; line-height: 27px; font-family: Georgia, serif; color: #444341; padding: 10px;">
5 of
<strong style="color:#137CBD">Yarn Ball</strong><br>
<em>SKU:</em> YARNBALL <dl style="margin:0; padding:0;">
<dt><strong><em>Style</em></strong></dt>
<dd style="margin:0; padding:0 0 0 9px;">
Red/White </dd>
</dl>
</td>
<td align="right" valign="top" style="font-size: 17px; line-height: 27px; font-family: Georgia, serif; color: #444341; padding: 10px;">
<span class="price">$25.00</span>
</td>
</tr>
</tbody>
<tbody>
<tr>
<td align="left" valign="top" style="font-size: 17px; line-height: 27px; font-family: Georgia, serif; color: #444341; padding: 10px;">
<strong style="color:#137CBD">Example Registration</strong><br>
<em>SKU:</em> EX_Reg-- <dl style="margin:0; padding:0;">
<dt><strong><em>Certification Type</em></strong></dt>
<dd style="margin:0; padding:0 0 0 9px;">
Recertification </dd>
<dt><strong><em>Date</em></strong></dt>
<dd style="margin:0; padding:0 0 0 9px;">
Sep 2, 2012 </dd>
<dt><strong><em>Category</em></strong></dt>
<dd style="margin:0; padding:0 0 0 9px;">
05, 07 </dd>
<dt><strong><em>Location</em></strong></dt>
<dd style="margin:0; padding:0 0 0 9px;">
Lincoln </dd>
</dl>
</td>
<td align="right" valign="top" style="font-size: 17px; line-height: 27px; font-family: Georgia, serif; color: #444341; padding: 10px;">
<span class="price">$50.00</span>
</td>
</tr>
</tbody>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%" style="border-bottom: 1px solid #D5D0C1; border-top:1px solid #D5D0C1;">
<tbody>
<tr class="subtotal">
<td align="right" style="font-size: 17px; line-height: 27px; font-family: Georgia, serif; color: #444341; padding: 10px;">
Subtotal </td>
<td align="right" style="font-size: 17px; line-height: 27px; font-family: Georgia, serif; color: #444341; padding: 10px;">
<span class="price">$75.00</span> </td>
</tr>
<tr class="shipping">
<td align="right" style="font-size: 17px; line-height: 27px; font-family: Georgia, serif; color: #444341; padding: 10px;">
Shipping & Handling </td>
<td align="right" style="font-size: 17px; line-height: 27px; font-family: Georgia, serif; color: #444341; padding: 10px;">
<span class="price">$14.82</span> </td>
</tr>
<tr class="grand_total">
<td align="right" style="font-size: 17px; line-height: 27px; font-family: Georgia, serif; color: #444341; padding: 10px;">
<strong>Grand Total</strong>
</td>
<td align="right" style="font-size: 17px; line-height: 27px; font-family: Georgia, serif; color: #444341; padding: 10px;">
<strong><span class="price">$89.82</span></strong>
</td>
</tr>
</tbody>
</table>
EOD;
$innerChild2->setTextAlt(<<<EOD
5 of Yarn Ball $25.00
SKU: YARNBALL
Style
Red/White
Example Registration $50.00
SKU: EX_Reg--
Certification Type
Recertification
Date
Sep 2, 2012
Category
05, 07
Location
Lincoln
------------------------------------------------------------------------------------------
Subtotal $75.00
Shipping & Handling $14.82
Grand Total $89.82
------------------------------------------------------------------------------------------
EOD
);
$mailer->addChild($child);
$child = new UNL_WDN_Emailer_Template_Band();
$child->background = '#137CBD';
$child->foreground = '#ffffff';
$child->headline = 'Additional Information';
$innerChild = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild->body = 'This is where I would put special information for the order that is not yet supported by magento.';
$child->addChild($innerChild);
$mailer->addChild($child);
$child = new UNL_WDN_Emailer_Template_Band();
$innerChild = new UNL_WDN_Emailer_Template_Button();
$innerChild->href = 'https://id.unl.edu/';
$innerChild->label = 'Manage Account';
$innerChild2 = new UNL_WDN_Emailer_Template_InnerWrapper();
$innerChild2->addChild($innerChild);
$child->addChild($innerChild2);
$innerChild = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild->cssStyles = 'font-size: 17px; line-height: 27px; font-family: Georgia, serif; color: #444341;';
$innerChild->includeDefaultStyles = false;
$innerChild->body = 'Thank you for shopping with us.';
$child->addChild($innerChild);
$innerChild = new UNL_WDN_Emailer_Template_TextBlock();
$innerChild->cssStyles = 'font-size: 20px; font-family: Georgia, serif;';
$innerChild->includeDefaultStyles = false;
$innerChild->addChild($link);
$child->addChild($innerChild);
$mailer->addChild($child);
// WHAT TO DO WITH MESSAGE
if (isset($argv[1])) {
if ($argv[1] == '-h') {
printUsage();
exit;
}
if ($argv[1] == 'html') {
echo $mailer->toHTML();
exit;
}
try {
if ($argc < 3) {
throw new InvalidArgumentException('Must provide <to_address> and <from_address>');
}
if (!filter_var($argv[1], FILTER_VALIDATE_EMAIL)) {
throw new InvalidArgumentException('Invalid <to_address>');
}
$mailer->to_address = $argv[1];
if (!filter_var($argv[2], FILTER_VALIDATE_EMAIL)) {
throw new InvalidArgumentException('Invalid <from_address>');
}
$mailer->from_address = $argv[2];
if (isset($argv[3])) {
$mailer->subject = $argv[3];
}
$mailer->send();
echo "Message sent\n";
} catch (Exception $e) {
echo 'Command Failed: ' . $e->getMessage() . "\n";
printUsage();
}
} else {
echo $mailer;
}
function printUsage()
{
global $argv;
echo 'Usage:' . "\n" .
' php ' . $argv[0] . "\n" .
' Outputs the text alternative' . "\n" .
' php ' . $argv[0] . ' html' . "\n" .
' Outputs the html alternative' . "\n" .
' php ' . $argv[0] . ' <to_address> <from_address> [<subject>]' . "\n" .
' Sends the message with the given addresses' . "\n";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment