diff --git a/code/Newsletter/Newsletter.php b/code/Newsletter/Newsletter.php index 58bc6200..bcb47faa 100755 --- a/code/Newsletter/Newsletter.php +++ b/code/Newsletter/Newsletter.php @@ -124,12 +124,13 @@ class Newsletter_SentRecipient extends DataObject { * * ParentID is the the Newsletter * Email and MemberID keep track of the recpients information - * Result has 3 possible values: "Sent", (mail() returned TRUE), "Failed" (mail() returned FALSE), or "Bounced" ({@see $email_bouncehandler}). + * Result has 4 possible values: "Sent", (mail() returned TRUE), "Failed" (mail() returned FALSE), + * "Bounced" ({@see $email_bouncehandler}), or "BlackListed" (sending to is disabled). */ static $db = array( "ParentID" => "Int", "Email" => "Varchar(255)", - "Result" => "Enum('Sent, Failed, Bounced', 'Sent')", + "Result" => "Enum('Sent, Failed, Bounced, BlackListed', 'Sent')", ); static $has_one = array( "Member" => "Member", diff --git a/code/Newsletter/NewsletterEmailProcess.php b/code/Newsletter/NewsletterEmailProcess.php index 7ba4a5ed..3a05efb4 100755 --- a/code/Newsletter/NewsletterEmailProcess.php +++ b/code/Newsletter/NewsletterEmailProcess.php @@ -46,25 +46,32 @@ class NewsletterEmailProcess extends BatchProcess { /** * Email Blacklisting Support */ - if($member->BlacklistedEmail && Email_BlackList::isBlocked($this->to)){ + if($member->BlacklistedEmail && Email_BlackList::isBlocked($address)){ $bounceRecord = new Email_BounceRecord(); $bounceRecord->BounceEmail = $member->Email; $bounceRecord->BounceTime = date("Y-m-d H:i:s",time()); $bounceRecord->BounceMessage = "BlackListed Email"; $bounceRecord->MemberID = $member->ID; $bounceRecord->write(); - continue; - } - - $e = new Newsletter_Email($this->nlType); - $e->setBody( $this->body ); - $e->setSubject( $this->subject ); - $e->setFrom( $this->from ); - $e->setTemplate( $this->nlType->Template ); - - - $e->populateTemplate( array( 'Member' => $member, 'FirstName' => $member->FirstName ) ); - $this->sendToAddress( $e, $address, $this->messageID, $member); + + // Log the blacklist for this specific Newsletter + $newsletter = new Newsletter_SentRecipient(); + $newsletter->Email = $address; + $newsletter->MemberID = $member->ID; + $newsletter->Result = 'BlackListed'; + $newsletter->ParentID = $this->newsletter->ID; + $newsletter->write(); + } else { + $e = new Newsletter_Email($this->nlType); + $e->setBody( $this->body ); + $e->setSubject( $this->subject ); + $e->setFrom( $this->from ); + $e->setTemplate( $this->nlType->Template ); + + + $e->populateTemplate( array( 'Member' => $member, 'FirstName' => $member->FirstName ) ); + $this->sendToAddress( $e, $address, $this->messageID, $member); + } } } diff --git a/templates/Newsletter_SentStatusReport.ss b/templates/Newsletter_SentStatusReport.ss index ee52169f..5eb8f156 100644 --- a/templates/Newsletter_SentStatusReport.ss +++ b/templates/Newsletter_SentStatusReport.ss @@ -46,6 +46,31 @@ <% end_if %> +<% if SentRecipients(BlackListed) %> +

Sending to the Following Recipients Did Not Occur Because They Are BlackListed

+ + + + + + + + + + + + <% control SentRecipients(BlackListed) %> + + + + + + <% end_control %> + + +
DateResult
$Email$LastEdited$Result
+<% end_if %> + <% if UnsentSubscribers %>

The Newsletter has Never Been Sent to Following Subscribers