vB Cron Based Email Problem:
Problem is working with alot of the larger and very active vBulletin forum clients, Ive noticed alot of complaints of email notification delays by members on this forums. When I look into vB MySQL databases mailqueue table, I see a back log of 30,000 to 60,000 emails queued up with the default 10 emails per batch setting. With email batch on a 10min vB Scheduled Task cron by default, you can imagine how long it would take for emails to clear the vB mail queue!
vbmailqueue.sh
So how do you figure out an optimal value for the number of emails to send per batch ? For VPS and dedicated server customers with root/SSH telnet access, I wrote a bash script, vbmailqueue.sh which can:
- output and display the entire mail queue
- count number of emails back logged in the mail queue
- provide the last mailqueue id value
- also display the current vB AdminCP email options.
- log all output to a time stamped text file for viewing and analysis
The vbmailqueue.sh script is available here. Just edit the script's 5 variables explained within the script, upload to server and make it executable. So if you uploaded script to /home/tools/vbmailqueue.sh (ASCII mode)
Code:
chmod +x /home/tools/vbmailqueue.sh cd /home/tools ./vbmailqueue.sh view ./vbmailqueue.sh count
vbmailqueue.sh output
menu options view the full mail queue by mailqueueid, count the number of emails queued and well debug is just something I had to setup to check I was getting the right last mailqueue id in the queue.
Code:
root@ [~/tools]# ./vbmailqueue.sh ./vbmailqueue.sh view ./vbmailqueue.sh count ./vbmailqueue.sh debug
Code:
root@ [~/tools]# ./vbmailqueue.sh count ------------------------------------------------------------------ vbmailqueue.sh 0.0.3 - George Liu (eva2000) vbtechsupport.com ------------------------------------------------------------------ As at: Mon Jun 4 07:51:04 CDT 2012 ------------------------------------------------------------------ First Mail Queue ID: 14181939 Last Mail Queue ID: 14181940 ------------------------------------------------------------------ vBulletin Mail Queue row size is: 2 ------------------------------------------------------------------ vBulletin email settings are set as follows: +----------------+------------+--------------------+--------------+ | varname | grouptitle | value | defaultvalue | +----------------+------------+--------------------+--------------+ | smtp_pass | email | | | | smtp_tls | email | ssl | none | | smtp_user | email | [email protected] | | | smtp_port | email | 465 | 25 | | smtp_host | email | smtp.gmail.com | | | use_smtp | email | 0 | | | utf8encode | email | 0 | 0 | | usebulkheader | email | 0 | 0 | | needfromemail | email | 0 | | | bounceemail | email | | | | mail_delay | email | 0 | 0 | | emailsendnum | email | 5000 | 50 | | mailqueue | email | 1 | 1 | | emailfloodtime | email | 10 | 60 | | usemailqueue | email | 1 | 1 | | secureemail | email | 1 | 1 | | enableemail | email | 1 | 1 | | displayemails | email | 1 | 1 | +----------------+------------+--------------------+--------------+ ------------------------------------------------------------------ Stats Output saved at: /root/vbmailqueuelogs/mailqueue_040612-075104.log ------------------------------------------------------------------ total 4.0K -rw-r--r-- 1 root root 2.2K Jun 4 07:51 mailqueue_040612-075104.log ------------------------------------------------------------------
Code:
root@ [~/tools]# ./vbmailqueue.sh view ------------------------------------------------------------------ vbmailqueue.sh 0.0.3 - George Liu (eva2000) vbtechsupport.com ------------------------------------------------------------------ As at: Mon Jun 4 07:51:12 CDT 2012 ------------------------------------------------------------------ +-------------+------------+ | mailqueueid | dateline | +-------------+------------+ | 14181939 | 1338814229 | | 14181940 | 1338814244 | +-------------+------------+ ------------------------------------------------------------------ Stats Output saved at: /root/vbmailqueuelogs/mailqueue_040612-075112.log ------------------------------------------------------------------ total 8.0K -rw-r--r-- 1 root root 2.4K Jun 4 07:51 mailqueue_040612-075104.log -rw-r--r-- 1 root root 681 Jun 4 07:51 mailqueue_040612-075112.log ------------------------------------------------------------------
If you are on shared hosting without SSH / Telnet access, you can check your mail queue size, via vB AdminCP -> Maintenance -> Diagnostics -> System Information -> Table Status. Find the mailqueue table and check row size.
Summary:
Basically, there are 3 ways to control the delay and mail queue.
- change email batch size
- change vB scheduled cron task for processing email queue
- disable cron based email sending
Further related vB articles for reading:
- What is Cron Based Email Sending?
- How do I enable/disable Cron Based Email Sending?
- How do I change the number of emails sent per batch?
- How do I change the delay between emails being sent?
Source: original personal blog article
I'm indeed in this situation where backlog for emails is more than 60000 emails to send.
I'm interessted in this sh file but can't found it attached to this post ... is it still available?
THanks
But i reuploaded script contents at https://gist.github.com/vbtechsupport/8329398