OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Limit emails per minute

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Limit emails per minute

Postby vlilloh » Tue Oct 02, 2012 1:22 am

Hi,

Is there any way to limit the number of emails per minute, per hour, ... in automatically Notify Users?

My server administrator tells me that the limit is around 80 emails per minute. And OJS seems that sends more than that amount and the server blocks all emails.

Cheers.
vlilloh
 
Posts: 281
Joined: Thu Feb 07, 2008 3:35 am
Location: Murcia, Spain

Re: Limit emails per minute

Postby asmecher » Tue Oct 02, 2012 11:13 am

Hi Vicente,

Hmm, I'd suggest checking your logs to see if there's evidence of someone using OJS to relay email. There are settings in config.inc.php, e.g. time_between_emails and max_recipients, that apply to non-editorial users. Or do you think this is arising because of the "Notify Users" mailouts?

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8345
Joined: Wed Aug 10, 2005 12:56 pm

Re: Limit emails per minute

Postby vlilloh » Wed Oct 03, 2012 3:11 am

Hi Alec,

Sorry, I myself attempt Notify Users, after publishing a new issue, but there is a firewall on the server blocking sending mass emails. The server administrator told me that I can skip this firewall if I send about 80 emails per minute or less. If I send more than 80 emails per minute, the firewall is enabled and blocks the sending of all emails. The firewall rules can not be changed.

time_between_emails and max_recipients parameters is the solution? What might be the appropriate values ​​for example in my case?

Cheers.
vlilloh
 
Posts: 281
Joined: Thu Feb 07, 2008 3:35 am
Location: Murcia, Spain

Re: Limit emails per minute

Postby asmecher » Wed Oct 03, 2012 9:01 am

Hi Vicente,

I see. There's no email throttling code currently in OJS, but I expect you'll only ever encounter this with the Notify Users feature, so I'd suggest considering two options:
  • Export your mailing list to an external tool for the mass mail-outs, or
  • Modify the mass-mailing code, lib/pkp/classes/mail/MassMail.inc.php, to introduce a delay between MailTemplate::send() calls.
PHP isn't great at performing batch jobs, i.e. as they get longer and longer there is more likelihood that the job will be killed by the web server, but unfortunately there's not much we can do about that.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8345
Joined: Wed Aug 10, 2005 12:56 pm

Re: Limit emails per minute

Postby vlilloh » Thu Oct 04, 2012 3:01 am

Hi Alec,

I like the MassMail.inc.php option. Is it difficult to insert a delay? Is it enough to change any parameter as "frequency" or "set_time_limit" in this file? Or programming/PHP skills are needed?

Cheers.
vlilloh
 
Posts: 281
Joined: Thu Feb 07, 2008 3:35 am
Location: Murcia, Spain

Re: Limit emails per minute

Postby asmecher » Thu Oct 04, 2012 8:51 am

Hi Vicente,

Just throwing code off the top of my head -- look in MassMail.inc.php for the loop:
Code: Select all
foreach ($realRecipients as $recipient) {
Just above that, initialize the $lastSendTime variable:
Code: Select all
$lastSendTime = 0;
Then, just inside the top of the loop, add a check and possible delay:
Code: Select all
    if ($lastSendTime == time()) {
        sleep(1);
    }
...and, inside the bottom of the loop...
Code: Select all
$lastSendTime = time();
This is untested but should work. Note that it'll send out mass email sending *tremendously* -- to around one email per second -- so consider your number of subscribers and multiply accordingly. Watch out for PHP time limits or impatient browsers, which may cause PHP-based batch jobs like this to fail partway through. If that happens, you'll probably have to look into other ways of sending mail, as PHP is not good at long jobs.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8345
Joined: Wed Aug 10, 2005 12:56 pm

Re: Limit emails per minute

Postby vlilloh » Fri Oct 05, 2012 4:08 am

Hi Alec,

Thank you very much! Ok, I'll test this to see how it goes.

Cheers.
vlilloh
 
Posts: 281
Joined: Thu Feb 07, 2008 3:35 am
Location: Murcia, Spain

Re: Limit emails per minute

Postby ganesh » Fri Jul 04, 2014 5:36 am

Dear Alec,

I am also facing the same type of problem.
Can we reset the time of email delay from 1 second to 2 seconds in case of MassMail.inc.php ?
Can it be possible through the above suggested code? Kindly explain.

Regards

Ganesh
ganesh
 
Posts: 22
Joined: Sun Oct 06, 2013 12:33 am

Re: Limit emails per minute

Postby asmecher » Fri Jul 04, 2014 9:56 am

Hi Ganesh,

Yes -- the number of seconds is specified in the call to sleep() in the above code.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8345
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: No registered users and 4 guests