We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Tutorial: Don't send emails to users based on their lastActivity!!! | Forum

Marcus Jun 30 '20

Hi folks if u care about ur out-going emails quota then this tutorials is for u.

Why is it important not to send emails to those users who haven't been back online for some extended period of time like in my case 3 months.

Case in most cases that particular user won't come back ever again or the email is no longer valid so ur robbing ur legit users from getting notifications by trying to send emails to ghosts lol.

I will post another part of this code that will make users conform their email after they have been gone for some time.

Lets get started. Keep in mind this tutorial if only for those using SMTP!!!

Open this file: ow_system_plugins\base\bol\mail_service.php

Find: private function mailToDtoList( BASE_CLASS_Mail $mail )

Add this code after: $resultList = array();

// my fix 1/2 start        
$ow_language = OW::getLanguage();
if($mailState['subject'] != $ow_language->text('base', 'email_verify_subject') || $mailState['subject'] != $ow_language->text('base', 'reset_password_mail_template_subject'))
$userLastActivityTimeStamp = BOL_UserService::getInstance()->findByEmail( $mailState['recipientEmailList'][0])->activityStamp;
if($userLastActivityTimeStamp < strtotime('-90 days')) return $resultList;
// my fix 1/2 end

Now search for: public function addToQueue( BASE_CLASS_Mail $mail )

Add this code after: $dtoList = $this->mailToDtoList($mail);

// my fix 2/2 start
if(empty($dtoList)) return;
// my fix 2/2 end

OK ur all set to go.

The Forum post is edited by Marcus Jun 30 '20
dave Jul 1 '20
Topic was moved from General Questions.