added watchdog mandrill result hook
This commit is contained in:
parent
23b96ab26f
commit
f8a18606ba
@ -660,20 +660,26 @@ function materio_user_get_role_by_name($name) {
|
|||||||
*/
|
*/
|
||||||
function materio_user_mandrill_mailsend_result($result) {
|
function materio_user_mandrill_mailsend_result($result) {
|
||||||
if ( in_array($result['status'], array('rejected', 'invalid', 'error')) ) {
|
if ( in_array($result['status'], array('rejected', 'invalid', 'error')) ) {
|
||||||
|
$email = $result['email'];
|
||||||
|
|
||||||
// remove email from pool
|
// remove email from pool
|
||||||
module_load_include('inc', 'simplenews', 'includes/simplenews.mail');
|
module_load_include('inc', 'simplenews', 'includes/simplenews.mail');
|
||||||
simplenews_delete_spool(array('mail'=>$result['email']));
|
simplenews_delete_spool(array('mail'=>$email));
|
||||||
|
watchdog("materio_user", "@mail rejected by mandrill, removed from simplenews spool", array("@mail"=>$email));
|
||||||
|
|
||||||
if ( in_array($result['status'], array('invalid')) ) {
|
if ( in_array($result['status'], array('invalid')) ) {
|
||||||
// unsubscribe user if mail does not exists
|
// unsubscribe user if mail does not exists
|
||||||
$subscriber = simplenews_subscriber_load_by_mail($result['email']);
|
$subscriber = simplenews_subscriber_load_by_mail($email);
|
||||||
if ($subscriber) {
|
if ($subscriber) {
|
||||||
simplenews_subscriber_delete($subscriber);
|
simplenews_subscriber_delete($subscriber);
|
||||||
}
|
}
|
||||||
// disable user
|
// disable user
|
||||||
$user = user_load_by_mail($result['email']);
|
$user = user_load_by_mail($email);
|
||||||
$user->status = 0;
|
// $user->status = 0;
|
||||||
user_save($user->uid);
|
user_save($user, array('status'=>0));
|
||||||
|
|
||||||
|
watchdog("materio_user", "@mail rejected as invalid by mandrill, removed from simplenews subscribers liste and user blocked", array("@mail"=>$email), WATCHDOG_WARNING, "/user/".$user->uid."/edit");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user