News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Newletter Mail Queue Not Working

Started by Randem, August 27, 2023, 01:22:22 AM

Previous topic - Next topic

Randem

Running Clean SMF 2.1.4 No Mods
Apache 2.4
VPS Server
Linux
PHP 8.1.22

We found that no mail will be sent from the mail queue due to one or more of these conditions:

in ScheduledTask.php line 770

if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '')
should be

if (empty($modSettings['mail_type']) || $modSettings['smtp_host'] != '')
The original line keeps php mail from sending anything for PHP is the default setting which is empty, so the routine will never run and will always attempt to run SMTP mail of which seem to choose the php.ini settings and not the SMF settings to run. So if your php.ini settings for SMTP are not current to where your mail goes out it will fail also. If there is no SMTP HOST, PHP Mail should be the default.

The change will check if using the default PHP mail setting is being used or if the SMTP HOST setting is not filled in and will default to PHP mail being used.


Furthermore if the setting mail_next_send is zero the cron job will not run ReduceMailQueue.

line 153 in cron.php

    if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time())
        AutoTask();
    elseif (!empty($modSettings['mail_next_send']) && $modSettings['mail_next_send'] < time())
        ReduceMailQueue();

Probably should be

elseif (empty($modSettings['mail_next_send']) || $modSettings['mail_next_send'] < time())
ReduceMailQueue();

or just:

elseif ($modSettings['mail_next_send'] < time())
ReduceMailQueue();


I used a combination to check if the time has elapsed and if there are entries in the mail_queue table which should trigger sending mail:

    $request = $smcFunc['db_query']('', '
        SELECT `id_mail`
        FROM {db_prefix}mail_queue',
        array(
        )
    );

    if (($modSettings['mail_next_send'] < time()) && ($smcFunc['db_num_rows']($request) != 0))
ReduceMailQueue();
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Advertisement: