diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/com/ext/interspire_email/email.php iem/admin/com/ext/interspire_email/email.php
--- iem.unpatched/admin/com/ext/interspire_email/email.php 2010-08-22 20:22:28.000000000 -0500
+++ iem/admin/com/ext/interspire_email/email.php 2011-10-25 05:51:40.000000000 -0500
@@ -12,6 +12,8 @@
* @package API
* @subpackage Email_API
*/
+require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/includes/config_greenarrow.php');
+
class Email_API
{
@@ -488,7 +490,11 @@
*/
var $ErrorCodeSMTPEnhanced = false;
-
+ /**
+ * If true, then we will setup the VEPR so that emails are removed after a single hard bounce.
+ * @var Boolean
+ */
+ var $remove_with_single_hard_bounce = false;
/**
@@ -790,7 +796,10 @@
$this->DebugMemUsage('assembling headers');
- $headers = 'Return-Path: ' . $this->BounceAddress . $this->_newline;
+ $headers = '';
+
+ if ( ! $this->_BounceAddressHasVERP($this->BounceAddress) )
+ $headers .= 'Return-Path: ' . $this->BounceAddress . $this->_newline;
$headers .= 'Date: ' . date('r') . $this->_newline;
@@ -1475,6 +1484,14 @@
*/
function _Send_Email(&$rcpt_to, &$to, &$subject, &$body, &$headers)
{
+ if ( GREENARROW_INTEGRATION_ENABLED ) {
+ $this_headers = rtrim($headers);
+ if ( $this_headers <> '' ) $this_headers .= "\n";
+ $this_headers .= $this->_GetGreenArrowXMailerInfoHeader($rcpt_to) . "\n";
+ }
+ else {
+ $this_headers = $headers;
+ }
$this->DebugMemUsage('rcpt_to: ' . $rcpt_to . '; to: ' . $to . '; subject: ' . $subject . '; headers: ' . $headers);
@@ -1497,7 +1514,7 @@
if (!$this->TestMode) {
if ($this->SMTPServer) {
$this->DebugMemUsage('sending through smtp server');
- return $this->_Send_SMTP($rcpt_to, $to, $subject, $body, $headers);
+ return $this->_Send_SMTP($rcpt_to, $to, $subject, $body, $this_headers);
}
}
@@ -1518,24 +1535,26 @@
if ($this->safe_mode || !$this->BounceAddress) {
if (!$this->TestMode) {
- $mail_result = mail($to, $subject, $body, rtrim($headers));
+ $mail_result = mail($to, $subject, $body, rtrim($this_headers));
} else {
$mail_result = true;
}
$this->DebugMemUsage('no bounce address or safe mode is on');
} else {
- if (is_null($this->_sendmailparameters)) {
+ $this_bounce_address = $this->_CustomizeBounceAddress($this->BounceAddress, $rcpt_to);
+
+ if ( $this->_BounceAddressHasVERP($this->BounceAddress) || is_null($this->_sendmailparameters) ) {
$old_from = ini_get('sendmail_from');
- ini_set('sendmail_from', $this->BounceAddress);
- $params = sprintf('-f%s', $this->BounceAddress);
+ ini_set('sendmail_from', $this_bounce_address);
+ $params = sprintf('-f%s', $this_bounce_address);
$this->_sendmailparameters = $params;
}
$this->DebugMemUsage('bounce address set to ' . $this->_sendmailparameters);
if (!$this->TestMode) {
- $mail_result = mail($to, $subject, $body, rtrim($headers), $this->_sendmailparameters);
+ $mail_result = mail($to, $subject, $body, rtrim($this_headers), $this->_sendmailparameters);
} else {
$mail_result = true;
}
@@ -1577,6 +1596,7 @@
$this->DebugMemUsage('Connection is ' . gettype($connection));
+ $this_bounce_address = $this->_CustomizeBounceAddress($this->BounceAddress, $rcpt_to);
if (!$connection) {
$this->DebugMemUsage('No connection');
@@ -1585,7 +1605,7 @@
if ($this->_SMTPPipeline) {
$cmds = array();
- $cmds[] = "MAIL FROM:<" . $this->BounceAddress . ">";
+ $cmds[] = "MAIL FROM:<" . $this_bounce_address . ">";
$cmds[] = "RCPT TO:<" . $rcpt_to . ">";
$data = implode($cmds, $this->_smtp_newline);
if (!$this->_Put_Smtp_Connection($data)) {
@@ -1612,7 +1632,7 @@
return $this->_Send_SmtpData($rcpt_to, $to, $subject, $body, $headers);
}
- $data = "MAIL FROM:<" . $this->BounceAddress . ">";
+ $data = "MAIL FROM:<" . $this_bounce_address . ">";
$this->DebugMemUsage('Trying to put ' . $data);
@@ -1694,7 +1714,6 @@
*/
function _Send_SmtpData(&$rcpt_to, &$to, &$subject, &$body, &$headers)
{
-
$data = "DATA";
$this->DebugMemUsage('Trying to put ' . $data);
@@ -1727,7 +1746,19 @@
return array(false, $this->Error);
}
- $msg = "To: " . $to . $this->_smtp_newline . "Subject: " . $subject . $this->_smtp_newline . $headers . $this->_smtp_newline . preg_replace('/^\.(\r|\n)/m', ' .${1}', $body);
+ $greenarrow_headers = '';
+ if ( GREENARROW_INTEGRATION_ENABLED )
+ {
+ $this_mtaid = getenv("GREENARROW_MTAID");
+ $this_listid = getenv("GREENARROW_LISTID");
+ $this_sendid = getenv("GREENARROW_SENDID");
+
+ if ( $this_mtaid != '' ) $greenarrow_headers .= 'X-GreenArrow-MtaID: ' . $this_mtaid . $this->_smtp_newline;
+ if ( $this_listid != '' ) $greenarrow_headers .= 'X-GreenArrow-ListID: ' . $this_listid . $this->_smtp_newline;
+ if ( $this_sendid != '' ) $greenarrow_headers .= 'X-GreenArrow-SendID: ' . $this_sendid . $this->_smtp_newline;
+ }
+
+ $msg = $greenarrow_headers . "To: " . $to . $this->_smtp_newline . "Subject: " . $subject . $this->_smtp_newline . $headers . $this->_smtp_newline . preg_replace('/^\.(\r|\n)/m', ' .${1}', $body);
$msg = str_replace("\r\n","\n",$msg);
$msg = str_replace("\r","\n",$msg);
@@ -2655,6 +2686,40 @@
error_log(basename($file) . "\t" . $line . "\t" . $function . "\t" . number_format((memory_get_usage()/1024), 5) . "\n", 3, $this->MemoryLogFile);
}
}
+
+
+ function _BounceAddressHasVERP($orig_bounce_address)
+ {
+ return strpos($orig_bounce_address, '-%VERP%') ? 1 : 0;
+ }
+
+ function _CustomizeBounceAddress($orig_bounce_address, $recipient)
+ {
+ $this_listid = getenv("GREENARROW_LISTID");
+ $this_sendid = getenv("GREENARROW_SENDID");
+ $this_verp = ( $this_listid != "" && $this_sendid != "" )
+ ? ( "-" . $this_listid . "-" . $this_sendid . "-" . str_replace("@", "=", $recipient) . ( $this->remove_with_single_hard_bounce ? "=1" : "" ) )
+ : "";
+
+ return str_replace("-%VERP%", $this_verp, $orig_bounce_address);
+ }
+
+
+ function _GetGreenArrowXMailerInfoHeader($recipient)
+ {
+ $this_listid = getenv("GREENARROW_LISTID");
+ $this_sendid = getenv("GREENARROW_SENDID");
+
+ $this_data_to_encode = strtolower($this_listid . "," . $recipient . "," . $this_sendid);
+ $this_additional_header = "X-Mailer-Info: ".
+ str_rot13(str_replace(array('+','/','=',"\n"),array('-','_'),
+ base64_encode(str_rot13(strrev($this_data_to_encode)))));
+
+ return $this_additional_header;
+ }
+
+
+
}
?>
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/com/install/schema.mysql.php iem/admin/com/install/schema.mysql.php
--- iem.unpatched/admin/com/install/schema.mysql.php 2010-08-22 20:22:28.000000000 -0500
+++ iem/admin/com/install/schema.mysql.php 2011-06-30 11:45:01.000000000 -0500
@@ -277,7 +277,8 @@
agreedelete char(1) default '0',
agreedeleteall char(1) default '0',
visiblefields text not null,
- ownerid int(11) default 0 references %%TABLEPREFIX%%users(userid)
+ ownerid int(11) default 0 references %%TABLEPREFIX%%users(userid),
+ mailroute varchar(100)
) character set utf8 engine=innodb";
$queries[] = "CREATE TABLE %%TABLEPREFIX%%newsletters (
@@ -744,4 +745,16 @@
) CHARACTER SET UTF8 ENGINE=INNODB
";
+$queries[] = "CREATE TABLE %%TABLEPREFIX%%greenarrow_queue (
+ id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ event_type varchar(15) NOT NULL,
+ listid varchar(255),
+ email varchar(255),
+ statid varchar(255),
+ bounce_type varchar(255),
+ bounce_rule varchar(255),
+ bounce_message varchar(255),
+ bounce_time int(11)
+ ) character set utf8 engine=innodb";
+
require(dirname(__FILE__) . '/schema.indexes.php');
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/com/install/schema.pgsql.php iem/admin/com/install/schema.pgsql.php
--- iem.unpatched/admin/com/install/schema.pgsql.php 2010-08-22 20:22:28.000000000 -0500
+++ iem/admin/com/install/schema.pgsql.php 2011-06-30 11:45:01.000000000 -0500
@@ -286,7 +286,8 @@
agreedelete char(1) default '0',
agreedeleteall char(1) default '0',
visiblefields text not null,
- ownerid int default 0
+ ownerid int default 0,
+ mailroute varchar(100) default NULL
)";
$queries[] = "CREATE SEQUENCE %%TABLEPREFIX%%newsletters_sequence";
@@ -762,4 +763,18 @@
)
";
+$queries[] = 'CREATE SEQUENCE %%TABLEPREFIX%%greenarrow_queue_sequence;';
+$queries[] = 'CREATE TABLE %%TABLEPREFIX%%greenarrow_queue (
+ id INT DEFAULT NEXTVAL(\'%%TABLEPREFIX%%greenarrow_queue_sequence\') NOT NULL,
+ event_type VARCHAR(15) NOT NULL,
+ listid VARCHAR(255),
+ email VARCHAR(255),
+ statid VARCHAR(255),
+ bounce_type VARCHAR(255),
+ bounce_rule VARCHAR(255),
+ bounce_message VARCHAR(255),
+ bounce_time INT(11),
+ PRIMARY KEY (id)
+)';
+
require(dirname(__FILE__) . '/schema.indexes.php');
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/com/language/default/stats.php iem/admin/com/language/default/stats.php
--- iem.unpatched/admin/com/language/default/stats.php 2010-08-22 20:22:29.000000000 -0500
+++ iem/admin/com/language/default/stats.php 2011-10-27 08:01:46.000000000 -0500
@@ -254,6 +254,30 @@
define('LNG_HardBounces', 'Hard Bounces');
define('LNG_SoftBounces', 'Soft Bounces');
+define('LNG_Bounce_Rule_0', 'Non-bounce');
+define('LNG_Bounce_Rule_10', 'Bad address');
+define('LNG_Bounce_Rule_20', 'Soft failure - general');
+define('LNG_Bounce_Rule_21', 'Soft failure - DNS failure');
+define('LNG_Bounce_Rule_22', 'Soft failure - mailbox full');
+define('LNG_Bounce_Rule_23', 'Soft failure - message too large');
+define('LNG_Bounce_Rule_29', 'Soft failure - unable to connect');
+define('LNG_Bounce_Rule_30', 'Email address could not be retrieved');
+define('LNG_Bounce_Rule_40', 'General bounce');
+define('LNG_Bounce_Rule_50', 'Mail block - General');
+define('LNG_Bounce_Rule_51', 'Mail block - Known Spammer');
+define('LNG_Bounce_Rule_52', 'Mail block - Spam Content Detected');
+define('LNG_Bounce_Rule_53', 'Mail block - Attachment Detected');
+define('LNG_Bounce_Rule_54', 'Mail block - Relay Denied');
+define('LNG_Bounce_Rule_59', 'Mail block - Unable to connect');
+define('LNG_Bounce_Rule_60', 'Auto reply');
+define('LNG_Bounce_Rule_70', 'Transient bounce');
+define('LNG_Bounce_Rule_80', 'Subscribe request');
+define('LNG_Bounce_Rule_90', 'Unsubscribe request');
+define('LNG_Bounce_Rule_100', 'Challenge-response message');
+define('LNG_Bounce_Rule_110', 'Soft failure - Over MTA throttle limit');
+define('LNG_Bounce_Rule_120', 'Queue dumped');
+define('LNG_Bounce_Rule_121', 'Delivery paused then message expired');
+
/**
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/com/templates/lists_form.tpl iem/admin/com/templates/lists_form.tpl
--- iem.unpatched/admin/com/templates/lists_form.tpl 2010-08-22 20:22:28.000000000 -0500
+++ iem/admin/com/templates/lists_form.tpl 2011-06-30 11:45:01.000000000 -0500
@@ -248,6 +248,25 @@
{template="bounce_details"}
+
+
+
+ |
+
+
+
+ GreenArrow Integration
+ |
+
+
+
+ {template="Not_Required"}
+ VirtualMTA:
+ |
+
+
+ |
+
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/cron/greenarrow_integrate.php iem/admin/cron/greenarrow_integrate.php
--- iem.unpatched/admin/cron/greenarrow_integrate.php 1969-12-31 18:00:00.000000000 -0600
+++ iem/admin/cron/greenarrow_integrate.php 2011-10-25 05:42:44.000000000 -0500
@@ -0,0 +1,191 @@
+
+
+// Make sure that the IEM controller does NOT redirect request.
+if (!defined('IEM_NO_CONTROLLER')) {
+ define('IEM_NO_CONTROLLER', true);
+}
+
+// Displaying an open image does not need a session.
+if (!defined('IEM_NO_SESSION')) {
+ define('IEM_NO_SESSION', true);
+}
+
+// Require base sendstudio functionality. This connects to the database, sets up our base paths and so on.
+require_once dirname(dirname(dirname(__FILE__))) . '/admin/index.php';
+
+// This file lets us get api's, load language files and parse templates.
+require_once SENDSTUDIO_FUNCTION_DIRECTORY . '/sendstudio_functions.php';
+
+$sendstudio_functions = new Sendstudio_Functions();
+
+$statsapi = $sendstudio_functions->GetApi('Stats');
+$subscriberapi = $sendstudio_functions->GetApi('Subscribers');
+
+$db = $subscriberapi->Db;
+
+// ========= end setup of libraries ==========
+
+function get_subscriberid ($sub_api, $listid, $email)
+{
+ $rv = $sub_api->IsSubscriberOnList($email, array($listid), 0, false, false, false);
+ return $rv;
+}
+
+function strip_to_number ($input)
+{
+ return preg_replace('{x\d{6}$}', '', preg_replace('{^[a-zA-Z]+}', '', $input));
+}
+
+function greenarrow_process_queue()
+{
+ global $sendstudio_functions, $statsapi, $subscriberapi, $db;
+
+ // Lock the lock file to make sure we are the only one running
+
+ $lockfile = TEMP_DIRECTORY . "/greenarrow_cron.lock";
+
+ $fp = fopen($lockfile, "w+");
+ if (! $fp)
+ die("error: unable to open lockfile ($lockfile)");
+
+ if (! flock($fp, LOCK_EX | LOCK_NB))
+ {
+ // Someone else already has the lock, return silently
+ fclose($fp);
+ return 0;
+ }
+
+
+ // Select records from the queue table for processing
+
+ $result = $db->Query("SELECT * FROM ".SENDSTUDIO_TABLEPREFIX."greenarrow_queue ORDER BY id ASC");
+
+ while ( 1 )
+ {
+ // Get a record
+
+ $row = $db->Fetch($result);
+
+ if ( empty($row) )
+ break;
+
+ // Start a transaction
+
+ $db->Query("begin");
+
+ // Process a record
+
+ greenarrow_process_record($row);
+
+ // Delete the record in the queue table
+
+ $result2 = $db->Query("DELETE FROM ".SENDSTUDIO_TABLEPREFIX."greenarrow_queue WHERE id = " . ((int)$row['id']));
+ if ( ! $result2 )
+ die("error: unable to remove entry from queue");
+
+ // Commit
+
+ $db->Query("commit");
+
+ }
+
+ $result = null;
+
+ // Release lock
+
+ fclose($fp);
+
+}
+
+function greenarrow_process_record ($record)
+{
+ global $sendstudio_functions, $statsapi, $subscriberapi, $db;
+
+ $type = $record['event_type'];
+ if ( $type == '' ) die("error: missing type");
+
+ if ( $type == "hook_scomp" )
+ {
+
+ $listid = strip_to_number($record['listid']);
+ $email = $record['email'];
+
+ if ( $listid == '' ) die("error: missing listid");
+ if ( $email == '' ) die("error: missing email");
+
+ if ( get_subscriberid($subscriberapi, $listid, $email) )
+ {
+ list($success, $error_message) = $subscriberapi->UnsubscribeSubscriber($email, $listid);
+
+ if ( ! $success )
+ die("error: $error_message");
+ }
+
+ }
+ else if ( $type == "hook_bounce" )
+ {
+ $listid = strip_to_number($record['listid']);
+ $email = $record['email'];
+ $bounce_time = $record['bounce_time'];
+
+ if ( $listid == '' ) die("error: missing listid");
+ if ( $email == '' ) die("error: missing email");
+ if ( $bounce_time == '' ) die("error: missing bounce_time");
+
+ if ( get_subscriberid($subscriberapi, $listid, $email)
+ && ! $subscriberapi->IsBounceSubscriber($email, $listid) )
+ {
+ list($success, $error_message) = $subscriberapi->BounceSubscriber($email, $listid, 0, $bounce_time);
+
+ if ( ! $success )
+ die("error: $error_message");
+ }
+
+ }
+ else if ( $type == "hook_stat" )
+ {
+ $listid = strip_to_number($record['listid']);
+ $email = $record['email'];
+ $statid = strip_to_number($record['statid']);
+ $bounce_type = $record['bounce_type'];
+ $bounce_rule = $record['bounce_rule'];
+ $bounce_message = $record['bounce_message'];
+ $bounce_time = $record['bounce_time'];
+
+ if ( $listid == '' ) die("error: missing listid");
+ if ( $email == '' ) die("error: missing email");
+ if ( $bounce_type == '' ) die("error: missing bounce_type");
+ if ( $bounce_rule == '' ) die("error: missing bounce_rule");
+ if ( $bounce_time == '' ) die("error: missing bounce_time");
+
+ // note: don't record stats for mail sent from confirmation form, which will have a statid that beins with "0t"
+
+ if ( $bounce_type != 'c' && substr($statid, 0, 2) != '0t' )
+ {
+ if ( $bounce_type == 'h' ) { $type_iem = "hard"; }
+ else if ( $bounce_type == 's' ) { $type_iem = "soft"; }
+ else if ( $bounce_type == 'o' ) { $type_iem = "soft"; }
+ else { die("error: unknown bounce_type ($bounce_type)"); }
+
+ $subscriberid = get_subscriberid($subscriberapi, $listid, $email);
+
+ if ( $subscriberid )
+ {
+ $subscriberapi->RecordBounceInfo($subscriberid, $statid, $listid, $type_iem, $bounce_rule, $bounce_message, $bounce_time, true);
+ list($success, $error_message) = $statsapi->RecordBounceInfo($subscriberid, $statid, $type_iem);
+ }
+
+ }
+
+ }
+ else
+ {
+ die("error: invalid type ($type)");
+ }
+
+}
+
+greenarrow_process_queue();
+
+
+?>
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/functions/api/jobs_autoresponders.php iem/admin/functions/api/jobs_autoresponders.php
--- iem.unpatched/admin/functions/api/jobs_autoresponders.php 2010-08-22 20:22:25.000000000 -0500
+++ iem/admin/functions/api/jobs_autoresponders.php 2011-06-30 11:45:01.000000000 -0500
@@ -590,6 +590,10 @@
$this->Email_API->Set('statid', $this->statid);
$this->Email_API->Set('listids', array($this->listid));
+ putenv("GREENARROW_SENDID=" . GREENARROW_SENDID_LISTID_PREFIX . $this->statid . "x" . date("ymd"));
+ putenv("GREENARROW_LISTID=" . GREENARROW_SENDID_LISTID_PREFIX . $this->listid);
+ putenv("GREENARROW_MTAID=" . $this->Lists_API->mailroute);
+
$this->Email_API->SetSmtp(SENDSTUDIO_SMTP_SERVER, SENDSTUDIO_SMTP_USERNAME, @base64_decode(SENDSTUDIO_SMTP_PASSWORD), SENDSTUDIO_SMTP_PORT);
if ($this->user->smtpserver) {
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/functions/api/lists.php iem/admin/functions/api/lists.php
--- iem.unpatched/admin/functions/api/lists.php 2010-08-22 20:22:25.000000000 -0500
+++ iem/admin/functions/api/lists.php 2011-06-30 11:45:01.000000000 -0500
@@ -179,6 +179,13 @@
var $createdate = 0;
/**
+ * The high-speed-MTA mail route to use for this mailing list (text)
+ *
+ * @var Int
+ */
+ var $mailroute = '';
+
+ /**
* Default Order to show templates in.
* @see GetLists
*
@@ -298,6 +305,7 @@
$this->companyname = $list['companyname'];
$this->companyphone = $list['companyphone'];
$this->companyaddress = $list['companyaddress'];
+ $this->mailroute = $list['mailroute'];
$field_assocs = array();
$query = "SELECT fieldid FROM " . SENDSTUDIO_TABLEPREFIX . "customfield_lists WHERE listid=" . intval($listid);
@@ -344,7 +352,8 @@
'processbounce' => intval($this->processbounce),
'agreedelete' => intval($this->agreedelete),
'agreedeleteall' => intval($this->agreedeleteall),
- 'visiblefields' => $this->Db->Quote($this->visiblefields)
+ 'visiblefields' => $this->Db->Quote($this->visiblefields),
+ 'mailroute' => $this->Db->Quote($this->mailroute)
);
$query = "
@@ -354,14 +363,16 @@
imapaccount, bounceserver, bounceusername, bouncepassword, extramailsettings,
companyname, companyaddress, companyphone,
ownerid, subscribecount, unsubscribecount,
- processbounce, agreedelete, agreedeleteall, visiblefields
+ processbounce, agreedelete, agreedeleteall, visiblefields,
+ mailroute
) VALUES (
'{$tempQuoted['name']}', '{$tempQuoted['owneremail']}', '{$tempQuoted['ownername']}',
'{$tempQuoted['bounceemail']}', '{$tempQuoted['replytoemail']}', '{$tempQuoted['format']}', {$tempQuoted['createdate']}, '{$tempQuoted['notifyowner']}',
'{$tempQuoted['imapaccount']}', '{$tempQuoted['bounceserver']}', '{$tempQuoted['bounceusername']}', '{$tempQuoted['bouncepassword']}', '{$tempQuoted['extramailsettings']}',
'{$tempQuoted['companyname']}', '{$tempQuoted['companyaddress']}', '{$tempQuoted['companyphone']}',
{$tempQuoted['ownerid']}, 0, 0,
- '{$tempQuoted['processbounce']}', '{$tempQuoted['agreedelete']}', '{$tempQuoted['agreedeleteall']}', '{$tempQuoted['visiblefields']}'
+ '{$tempQuoted['processbounce']}', '{$tempQuoted['agreedelete']}', '{$tempQuoted['agreedeleteall']}', '{$tempQuoted['visiblefields']}',
+ '{$tempQuoted['mailroute']}'
)
";
@@ -517,6 +528,7 @@
$this->extramailsettings = '';
$this->subscribecount = 0;
$this->unsubscribecount = 0;
+ $this->mailroute = '';
}
/**
@@ -822,7 +834,7 @@
$query = "UPDATE " . SENDSTUDIO_TABLEPREFIX . "lists SET name='" . $this->Db->Quote($this->name) . "', ownername='" . $this->Db->Quote($this->ownername) . "', owneremail='" . $this->Db->Quote($this->owneremail) . "', bounceemail='" . $this->Db->Quote($this->bounceemail) . "', replytoemail='" . $this->Db->Quote($this->replytoemail) . "', notifyowner='" . $this->Db->Quote((int)$this->notifyowner) . "', imapaccount='" . $this->Db->Quote((int)$this->imapaccount) . "', format='" . $this->Db->Quote($this->format) . "', bounceserver='" . $this->Db->Quote($this->bounceserver) . "', bounceusername='" . $this->Db->Quote($this->bounceusername) . "', bouncepassword='" .
$this->Db->Quote(base64_encode($this->bouncepassword)) . "',visiblefields='" .
- $this->Db->Quote($this->visiblefields) . "', extramailsettings='" . $this->Db->Quote($this->extramailsettings) . "', companyname='" . $this->Db->Quote($this->companyname) . "', companyaddress='" . $this->Db->Quote($this->companyaddress) . "', companyphone='" . $this->Db->Quote($this->companyphone) . "', processbounce='" . intval($this->processbounce) . "', agreedelete='" . intval($this->agreedelete) . "', agreedeleteall='" . intval($this->agreedeleteall) . "' WHERE listid=" . intval($this->listid);
+ $this->Db->Quote($this->visiblefields) . "', extramailsettings='" . $this->Db->Quote($this->extramailsettings) . "', companyname='" . $this->Db->Quote($this->companyname) . "', companyaddress='" . $this->Db->Quote($this->companyaddress) . "', companyphone='" . $this->Db->Quote($this->companyphone) . "', processbounce='" . intval($this->processbounce) . "', agreedelete='" . intval($this->agreedelete) . "', agreedeleteall='" . intval($this->agreedeleteall) . "', mailroute='" . $this->Db->Quote($this->mailroute) . "' WHERE listid=" . intval($this->listid);
$result = $this->Db->Query($query);
if (!$result) {
list($error, $level) = $this->Db->GetError();
@@ -1074,6 +1086,7 @@
$this->processbounce = (SENDSTUDIO_BOUNCE_SERVER == '' ? 0 : 1);
$this->agreedelete = 1;
$this->customfields = array();
+ $this->mailroute = '';
$this->Db->StartTransaction();
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/functions/api/send.php iem/admin/functions/api/send.php
--- iem.unpatched/admin/functions/api/send.php 2010-08-22 20:22:25.000000000 -0500
+++ iem/admin/functions/api/send.php 2011-06-30 11:45:01.000000000 -0500
@@ -13,6 +13,7 @@
* Require the base API class.
*/
require_once(dirname(__FILE__) . '/jobs.php');
+require_once(dirname(dirname(dirname(__FILE__))) . '/includes/config_greenarrow.php');
/**
* The send class handles basic processing of sending jobs.
@@ -419,6 +420,9 @@
$this->Email_API->Set('EmbedImages', $this->jobdetails['EmbedImages']);
$this->Email_API->Set('SentBy', $this->user->Get('userid'));
+ $mailroute = array_key_exists('MailRoute', $this->jobdetails) ? $this->jobdetails['MailRoute'] : "";
+ putenv("GREENARROW_MTAID=" . $mailroute);
+
if ($this->jobdetails['Multipart']) {
if ($this->newsletter['TextBody'] && $this->newsletter['HTMLBody'] && $this->newsletter['Format'] == 'b') {
$sent_format = 'm';
@@ -655,6 +659,9 @@
$subscriberinfo['newsletter'] = $this->jobdetails['Newsletter'];
$subscriberinfo['statid'] = $this->statid;
+ putenv("GREENARROW_SENDID=" . GREENARROW_SENDID_LISTID_PREFIX . $this->statid);
+ putenv("GREENARROW_LISTID=" . GREENARROW_SENDID_LISTID_PREFIX . $lid);
+
$this->Email_API->AddCustomFieldInfo($subscriberinfo['emailaddress'], $subscriberinfo);
$this->Email_API->AddDynamicContentInfo($this->dynamic_content_replacement);
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/functions/api/subscribers.php iem/admin/functions/api/subscribers.php
--- iem.unpatched/admin/functions/api/subscribers.php 2010-08-22 20:22:25.000000000 -0500
+++ iem/admin/functions/api/subscribers.php 2011-06-30 11:45:01.000000000 -0500
@@ -2066,7 +2066,7 @@
*
* @return Boolean Returns true if the subscriber has been completely bounced from the mailing list and made inactive. Returns false if they have not been made inactive.
*/
- function RecordBounceInfo($subscriberid=0, $bounce_statid=0, $bounce_listid=0, $bounce_type='', $bounce_rule='', $bounce_message='', $bounce_time=0)
+ function RecordBounceInfo($subscriberid=0, $bounce_statid=0, $bounce_listid=0, $bounce_type='', $bounce_rule='', $bounce_message='', $bounce_time=0, $do_not_disable_address=false)
{
$subscriberid = (int)$subscriberid;
$bounce_statid = (int)$bounce_statid;
@@ -2091,13 +2091,16 @@
$query = "INSERT INTO " . SENDSTUDIO_TABLEPREFIX . "list_subscriber_bounces(subscriberid, statid, listid, bouncetime, bouncetype, bouncerule, bouncemessage) VALUES (" . $subscriberid . ", " . $bounce_statid . ", " . $bounce_listid . ", " . $bounce_time . ", '" . $this->Db->Quote($bounce_type) . "', '" . $this->Db->Quote($bounce_rule) . "', '" . $this->Db->Quote($bounce_message) . "')";
$result = $this->Db->Query($query);
- $query = "SELECT COUNT(*) AS count FROM " . SENDSTUDIO_TABLEPREFIX . "list_subscriber_bounces WHERE subscriberid='" . $subscriberid . "'";
- $result = $this->Db->Query($query);
- $bounce_count = $this->Db->FetchOne($result, 'count');
+ if ( ! $do_not_disable_address )
+ {
+ $query = "SELECT COUNT(*) AS count FROM " . SENDSTUDIO_TABLEPREFIX . "list_subscriber_bounces WHERE subscriberid='" . $subscriberid . "'";
+ $result = $this->Db->Query($query);
+ $bounce_count = $this->Db->FetchOne($result, 'count');
- if ($bounce_count >= $this->softbounce_count || $bounce_type == 'hard') {
- $this->BounceSubscriber(false, $bounce_listid, $subscriberid, $bounce_time, true);
- return true;
+ if ($bounce_count >= $this->softbounce_count || $bounce_type == 'hard') {
+ $this->BounceSubscriber(false, $bounce_listid, $subscriberid, $bounce_time, true);
+ return true;
+ }
}
return false;
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/functions/lists.php iem/admin/functions/lists.php
--- iem.unpatched/admin/functions/lists.php 2010-08-22 20:22:25.000000000 -0500
+++ iem/admin/functions/lists.php 2011-06-30 11:45:01.000000000 -0500
@@ -486,6 +486,8 @@
$GLOBALS['CompanyAddress'] = htmlspecialchars($list->companyaddress, ENT_QUOTES, SENDSTUDIO_CHARSET);
$GLOBALS['CompanyPhone'] = htmlspecialchars($list->companyphone, ENT_QUOTES, SENDSTUDIO_CHARSET);
+ $GLOBALS['MailRoute'] = htmlspecialchars($list->mailroute, ENT_QUOTES, SENDSTUDIO_CHARSET);
+
$GLOBALS['NotifyOwner'] = ($list->notifyowner) ? ' CHECKED' : '';
if ($user->HasAccess('Lists', 'BounceSettings')) {
@@ -709,6 +711,8 @@
$list->companyaddress = $_POST['CompanyAddress'];
$list->companyphone = $_POST['CompanyPhone'];
+ $list->mailroute = $_POST['MailRoute'];
+
$customfield_assocs = array();
if (isset($_POST['AvailableFields']) && is_array($_POST['AvailableFields'])) {
$customfield_assocs = $_POST['AvailableFields'];
@@ -1014,6 +1018,8 @@
$list->companyaddress = $_POST['CompanyAddress'];
$list->companyphone = $_POST['CompanyPhone'];
+ $list->mailroute = $_POST['MailRoute'];
+
$list->ownerid = $user->userid;
$customfield_assocs = array();
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/functions/send.php iem/admin/functions/send.php
--- iem.unpatched/admin/functions/send.php 2010-08-22 20:22:25.000000000 -0500
+++ iem/admin/functions/send.php 2011-06-30 11:45:01.000000000 -0500
@@ -340,6 +340,8 @@
$send_details['ReplyToEmail'] = (isset($_POST['replytoemail'])) ? $_POST['replytoemail'] : $send_details['SendFromEmail'];
$send_details['BounceEmail'] = (isset($_POST['bounceemail'])) ? $_POST['bounceemail'] : $send_details['SendFromEmail'];
+ $send_details['MailRoute'] = $_POST['mailroute'];
+
$newsletterapi = $this->GetApi('Newsletters');
$newsletterapi->Load($send_details['Newsletter']);
$archive = $newsletterapi->Archive();
@@ -1301,6 +1303,8 @@
$GLOBALS['ReplyToEmail'] = $listapi->Get('replytoemail');
$GLOBALS['BounceEmail'] = $listapi->Get('bounceemail');
+ $GLOBALS['MailRoute'] = $listapi->Get('mailroute');
+
$GLOBALS['ShowBounceInfo'] = 'none';
if ($user->HasAccess('Lists', 'BounceSettings')) {
diff -rNu --exclude=storage --exclude=subscribers.php.orig --exclude=send.php.orig iem.unpatched/admin/includes/config_greenarrow.php iem/admin/includes/config_greenarrow.php
--- iem.unpatched/admin/includes/config_greenarrow.php 1969-12-31 18:00:00.000000000 -0600
+++ iem/admin/includes/config_greenarrow.php 2011-06-30 11:45:01.000000000 -0500
@@ -0,0 +1,6 @@
+ $listid) {
// if they are on the 'ignore' list, keep going and don't add them to this particular list.
if (in_array($listid, $contact_ignore_lists)) {
@@ -413,6 +414,7 @@
// if they are not confirmed, we should remove them then re-add them (so they get a new confirm code and new confirmation email).
$subscriberapi->DeleteSubscriber($email, $listid);
$subscriber_id = $subscriberapi->AddToList($email, $listid, true, true);
+ $listid_of_added_subscriber = $listid;
$subscriber['subscriberid'] = $subscriber_id;
@@ -446,12 +448,20 @@
// if we need to confirm the new subscriber, do it here.
if ($formapi->Get('requireconfirm') == true && sizeof($lists) != sizeof($contact_ignore_lists)) {
+ $listid = GREENARROW_SENDID_LISTID_PREFIX . $listid_of_added_subscriber;
+ $sendid = GREENARROW_SENDID_LISTID_PREFIX . "0t" . date('ymd');
+
+ putenv("GREENARROW_LISTID=" . $listid);
+ putenv("GREENARROW_SENDID=" . $sendid);
+
$emailapi->Set('Subject', $formapi->GetPage('ConfirmPage', 'emailsubject'));
$emailapi->Set('FromName', $formapi->GetPage('ConfirmPage', 'sendfromname'));
$emailapi->Set('FromAddress', $formapi->GetPage('ConfirmPage', 'sendfromemail'));
$emailapi->Set('ReplyTo', $formapi->GetPage('ConfirmPage', 'replytoemail'));
$emailapi->Set('BounceAddress', $formapi->GetPage('ConfirmPage', 'bounceemail'));
+ $emailapi->remove_with_single_hard_bounce = true;
+
$emailapi->AddBody('text', $formapi->GetPage('ConfirmPage', 'emailtext'));
$emailapi->AddBody('html', $formapi->GetPage('ConfirmPage', 'emailhtml'));
@@ -462,6 +472,8 @@
$emailapi->Set('CharSet', SENDSTUDIO_CHARSET);
$mail_results = $emailapi->Send(true);
+ $emailapi->remove_with_single_hard_bounce = false;
+
$confirmurl = $formapi->GetPage('ConfirmPage', 'url');
if ($confirmurl) {
header('Location: ' . $confirmurl);