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
* 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",

View File

@ -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);
}
}
}

View File

@ -46,6 +46,31 @@
</table>
<% 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 %>
<h2>The Newsletter has Never Been Sent to Following Subscribers</h2>
<table class="CMSList">