elofgren: NEW FEATURE: Log any attempts to send Newsletters to Emails that are blacklisted and show a 'Sending to the Following Recipients Did Not Occur Because They Are BlackListed?' report on the 'Sent Status Report' of Newsletters.

(merged from branches/gsoc)


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@42038 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2007-09-16 02:17:14 +00:00
parent bba347331f
commit be99502d53
3 changed files with 48 additions and 15 deletions

View File

@ -124,12 +124,13 @@ class Newsletter_SentRecipient extends DataObject {
* *
* ParentID is the the Newsletter * ParentID is the the Newsletter
* Email and MemberID keep track of the recpients information * 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( static $db = array(
"ParentID" => "Int", "ParentID" => "Int",
"Email" => "Varchar(255)", "Email" => "Varchar(255)",
"Result" => "Enum('Sent, Failed, Bounced', 'Sent')", "Result" => "Enum('Sent, Failed, Bounced, BlackListed', 'Sent')",
); );
static $has_one = array( static $has_one = array(
"Member" => "Member", "Member" => "Member",

View File

@ -46,16 +46,22 @@ class NewsletterEmailProcess extends BatchProcess {
/** /**
* Email Blacklisting Support * Email Blacklisting Support
*/ */
if($member->BlacklistedEmail && Email_BlackList::isBlocked($this->to)){ if($member->BlacklistedEmail && Email_BlackList::isBlocked($address)){
$bounceRecord = new Email_BounceRecord(); $bounceRecord = new Email_BounceRecord();
$bounceRecord->BounceEmail = $member->Email; $bounceRecord->BounceEmail = $member->Email;
$bounceRecord->BounceTime = date("Y-m-d H:i:s",time()); $bounceRecord->BounceTime = date("Y-m-d H:i:s",time());
$bounceRecord->BounceMessage = "BlackListed Email"; $bounceRecord->BounceMessage = "BlackListed Email";
$bounceRecord->MemberID = $member->ID; $bounceRecord->MemberID = $member->ID;
$bounceRecord->write(); $bounceRecord->write();
continue;
}
// 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 = new Newsletter_Email($this->nlType);
$e->setBody( $this->body ); $e->setBody( $this->body );
$e->setSubject( $this->subject ); $e->setSubject( $this->subject );
@ -67,6 +73,7 @@ class NewsletterEmailProcess extends BatchProcess {
$this->sendToAddress( $e, $address, $this->messageID, $member); $this->sendToAddress( $e, $address, $this->messageID, $member);
} }
} }
}
if( $this->current >= count( $this->objects ) ) if( $this->current >= count( $this->objects ) )
return $this->complete(); return $this->complete();

View File

@ -46,6 +46,31 @@
</table> </table>
<% end_if %> <% end_if %>
<% if SentRecipients(BlackListed) %>
<h2 class="error" style="width:auto;">Sending to the Following Recipients Did Not Occur Because They Are BlackListed</h2>
<table class="CMSList">
<thead>
<tr>
<th class="Email" style="width:33%">Email</th>
<th>Date</th>
<th>Result</th>
</tr>
</thead>
<tbody>
<% control SentRecipients(BlackListed) %>
<tr>
<td>$Email</td>
<td>$LastEdited</td>
<td>$Result</td>
</tr>
<% end_control %>
</tbody>
</table>
<% end_if %>
<% if UnsentSubscribers %> <% if UnsentSubscribers %>
<h2>The Newsletter has Never Been Sent to Following Subscribers</h2> <h2>The Newsletter has Never Been Sent to Following Subscribers</h2>
<table class="CMSList"> <table class="CMSList">