mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
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:
parent
bba347331f
commit
be99502d53
@ -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",
|
||||||
|
@ -46,25 +46,32 @@ 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
$e = new Newsletter_Email($this->nlType);
|
// Log the blacklist for this specific Newsletter
|
||||||
$e->setBody( $this->body );
|
$newsletter = new Newsletter_SentRecipient();
|
||||||
$e->setSubject( $this->subject );
|
$newsletter->Email = $address;
|
||||||
$e->setFrom( $this->from );
|
$newsletter->MemberID = $member->ID;
|
||||||
$e->setTemplate( $this->nlType->Template );
|
$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 ) );
|
$e->populateTemplate( array( 'Member' => $member, 'FirstName' => $member->FirstName ) );
|
||||||
$this->sendToAddress( $e, $address, $this->messageID, $member);
|
$this->sendToAddress( $e, $address, $this->messageID, $member);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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">
|
||||||
|
Loading…
Reference in New Issue
Block a user