• Resolved tetrakern

    (@tetrakern)


    Hello again,

    it’s been a while. Still grateful for the previous help. Anyway, I got yet another problem, namely that while the plugin works and emails are being sent (through an external SMTP service, which is working as well) — they are only partially sent. About 40 of 130 in the last case.

    I did not have a logger running because that would have been useful. However, I do have the log of MailerSend and as it turned out, the service only ever received these 40 emails. The rest never made it over the wire.

    We triggered the emails manually, if that matters. My best guess is that the script just stopped at some point for whatever reason (we are on a shared host, so we do not have endless server resources). I actually suck at debugging. Last error log contains stuff from May with lots of “WordPress database error Table” but nothing for this time.

    We had problems with emails for a while but thought this to be due to the lack of a proper SMTP service, which has now been amended yet the issue persists. MailerSend allows up to 12,000 emails on the free tier per month, so we are good on that front. Note that emails to cancel subscriptions, etc. are going out. So the site can definitely send emails, just not in bulk, apparently. Just silent failure.

    • This topic was modified 2 years, 2 months ago by tetrakern. Reason: Typo

    The page I need help with: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author vandestouwe

    (@vandestouwe)

    What is de maximum execution time for a task. According your provider?

    Thread Starter tetrakern

    (@tetrakern)

    I have set it to 300 in the hPanel, the info in WordPress shows 240 though. Curious.

    Edit: I’m still looking in case you meant another value than “max_execution_time”.

    • This reply was modified 2 years, 2 months ago by tetrakern. Reason: Clarification
    Thread Starter tetrakern

    (@tetrakern)

    Okay, I got some new information after the next batch of emails not going out.

    So, the mail logger did not catch any failed emails going out, so wp_mail was definitely not triggered for them.

    Another curiosity: Two categories applied here, but when I got the email (for once), only one of them was mentioned although I’m subscribed to both. The first one (Chapters) has currently 11 subscribers, the other (Crimson Lips) has 126.

    The Chapters category is relatively new, Crimson Lips is as old as the site. No idea if that piece of information is useful but here you go.

    There has been no new error logged, unfortunately. The debug.log hasn’t anything helpful either.

    A total of 43 emails has been sent through MailerSend, which is rather consistent with the last batch and about a third of what should have been.

    Plugin Author vandestouwe

    (@vandestouwe)

    Please install a mail logger so we can see what is factually being send by STC

    • This reply was modified 2 years, 2 months ago by vandestouwe.
    Thread Starter tetrakern

    (@tetrakern)

    I already did. Only the mentioned mails have been sent. No failures recorded.

    Edit: My best guess is that the other recipients are never queried for some reason.

    • This reply was modified 2 years, 2 months ago by tetrakern.
    Thread Starter tetrakern

    (@tetrakern)

    There are some more anomalies.

    On my local development and staging sites, I get ( ! ) Warning: Undefined array key "cron_time" in .../wp-content/plugins/subscribe-to-category/subscribe-to-category.php on line 28 and several Warning: Cannot modify header information when I try to activate the plugin. This only happened after reinstalling tho, which I won’t do on production for now.

    I did remove and reinstall it before that. Because I noticed some differences to the manual and wanted to see whether a fresh install helps.

    Other things I noticed:
    * There are no categories checkboxes on export/import like in the manual.
    * The “Resent” option is always there regardless of the setting.

    • This reply was modified 2 years, 2 months ago by tetrakern.
    • This reply was modified 2 years, 2 months ago by tetrakern.
    Thread Starter tetrakern

    (@tetrakern)

    So I was able to resolve the issue with the warnings. Turns out the options got deleted somehow and were not set on activation. Doing it manually in the settings got rid of these issues at least. So I’ll try turning it on and off again on the production site, I suppose, though I do not see how this would help.

    Edit: Now I wonder. Since I have warnings and such turned off on the live site, did these errors exist there as well and could they have been responsible. What was missing was the daily schedule time, which I did not use but got me an angry warning. Although if that was somehow responsible, I would have suspected nothing to work at all.

    • This reply was modified 2 years, 2 months ago by tetrakern.
    Thread Starter tetrakern

    (@tetrakern)

    I have new information. Maybe. Well, I added a little debug code to the plugin to send myself the $emails array as JSON. So at the very least I can confirm that all recipients have been queried. Actually, in one case there were too many nodes but that could mean anything. So the error is not there.

    I then send myself an email every time the sleep( 2 ) is triggered and got four mails for 124 emails, which checks out with the interval of 25. Dang, not here either.

    So it’s not the query, it’s also not the loop. Having no other option, I did send an actual test email to 124 subscribers. Well, that got me some results, at least.

    Got this one the console: Failed to load resource: the server responded with a status of 524 ()

    Got an alert with “Problem calling: force_run | Code: undefined | Exception: undefined”.

    Got one 25 batch notification but no more. So the process failed again after ~40-45 emails with no email failures in MailCatcher.

    Edit:

    Some stuff from the host:

    CPU usage reached 2.74%.
    RAM usage reached 128.15 MB.
    4 of max 180 processes were running.

    Edit 2:
    My WP_MEMORY_LIMIT is currently 40 M per script. Could that be the issue?

    • This reply was modified 2 years, 2 months ago by tetrakern.
    • This reply was modified 2 years, 2 months ago by tetrakern.
    Plugin Author vandestouwe

    (@vandestouwe)

    I think based on the information tje factual smtp transfer is timming out. Ao that bring me to my first question how long may one task run. This is controllable by you unless your provider is controlling it.

    It means that the cron job is factually cutoff / stopped by you provider because of overrunning the allowed time

    • This reply was modified 2 years, 2 months ago by vandestouwe.
    Thread Starter tetrakern

    (@tetrakern)

    I have already answered that. 240 seconds. I don’t know what is timing out here and it’s possible there is some other bullsh*ittery going on. I don’t care at this point.

    I asked some of my seniors for help and the common consensus was that running such a script on a non-dedicated system is not feasible in the first place.

    So I went ahead and did some modifications to the plugin myself, namely instead of using wp_mail in a loop of doom, I collect all emails in a JSON and send that to the bulk email API of MailerSend. Lo and behold, that went off without a hitch! Doesn’t even require that much change.

    In light of that, I would like to propose adding a callback hook for such purposes to the plugin because while adding this myself was easy, it will be an annoyance with updates. Having the option to override the sending behavior with your own would make the plugin far more usable for anyone with an external service (which anyone should use anyway). So you can still use all the other features but leave the emails to a system that can actually handle them.

    Essentially, it would be a hook that just gets the the email data as array. In that case, you also do not need the sleep anymore. There are many such services, but here is the example for MailerSend’s bulk API regarding what data is needed to do this. What I put into the loop:

    $mailersend_payload[] = array(
      'from' => ['email' => $email_from, 'name' => $website_name],
      'to' => array(
        ['email' => $email['email']]
      ),
      'subject' => $email_subject,
      'html' => $message
    );
    • This reply was modified 2 years, 2 months ago by tetrakern.
    • This reply was modified 2 years, 2 months ago by tetrakern. Reason: Formatting
    • This reply was modified 2 years, 2 months ago by tetrakern. Reason: More formatting
    Plugin Author vandestouwe

    (@vandestouwe)

    Thanks this is great. In the next version I wll add a callback

    Plugin Author vandestouwe

    (@vandestouwe)

    I created a wp mail replace hook for bulk sending
    this will be released in version 2.7.2

    Thread Starter tetrakern

    (@tetrakern)

    Nice!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Emails only partially sent’ is closed to new replies.