Getting an error with Decorator plugin
Posted: Fri Feb 20, 2009 12:09 pm
Here is my code
here is the error i'm getting
Notice: Undefined variable: swift in /var/www/vhosts/bpmgpublishingsystem.com/httpdocs/ejohnson-modules/processdist1.php on line 36
Fatal error: Call to a member function attachPlugin() on a non-object in /var/www/vhosts/bpmgpublishingsystem.com/httpdocs/ejohnson-modules/processdist1.php on line 36
Any ideas??
Code: Select all
<?php error_reporting(E_ALL); ini_set('display_errors', true); ?>
<?php
require_once "/var/www/vhosts/bpmgpublishingsystem.com/httpdocs/swift/lib/Swift.php";
require_once "/var/www/vhosts/bpmgpublishingsystem.com/httpdocs/swift/lib/Swift/Connection/SMTP.php";
require_once "/var/www/vhosts/bpmgpublishingsystem.com/httpdocs/swift/lib/Swift/Plugin/Decorator.php";
//// Get data/////
$from = $_POST['from'];
$email_list = $_POST['email'];
$subject = $_POST['subject'];
$msg = $_POST['message'];
//// Seperate the email Data/////////
$first_name = array();
$last_name = array();
$email_address = array();
$addys = preg_split('/\s*;\s*/', $email_list);
foreach($addys as $add)
{
preg_match('/^(.+\s)?([^\s<]+)\s*<([^>]*)>/', $add, $matches);
$first_name[] = $matches[1];
$last_name[] = $matches[2];
$email_address[] = $matches[3];
}
/// Array combine ///
$replacements = array();
$combo = array_combine ($email_address, $first_name);
$string = '<<First Name>>';
foreach ($combo as $email_a => $lname)
{
$replacements[] = array($email_a => array($string => $lname));
}
// Load the plugin with these replacements
$swift->attachPlugin(new Swift_Plugin_Decorator($replacements), "decorator");
///// Email Data
$swift =& new Swift(new Swift_Connection_SMTP("localhost"));
$message =& new Swift_Message($subject, $msg);
$recipients =& new Swift_RecipientList();
foreach ($email_address as $value)
{
$recipients->addTo($value);
}
//NOTE that Cc and Bcc recipients are IGNORED in a batch send
if ($swift->batchSend($message, $recipients, $from))
{
echo "message sent";
}
else
{
echo "message failed";
}
?>
Notice: Undefined variable: swift in /var/www/vhosts/bpmgpublishingsystem.com/httpdocs/ejohnson-modules/processdist1.php on line 36
Fatal error: Call to a member function attachPlugin() on a non-object in /var/www/vhosts/bpmgpublishingsystem.com/httpdocs/ejohnson-modules/processdist1.php on line 36
Any ideas??