Troubleshooting Failed emails

Okay folks, I get a lot of queries on here about the plugin and this is fine – to be expected in fact. The vast majority of them are about emails not arriving though so I thought I’d give you all some pointers.

Subscribe2 sends email notifications when you make a new post, it sends the email to you and puts all your subscribers email addresses into the BCC header of the email.

Now, the big problem with this is that this is a trick that SPAMMERS use! And for this reason a great deal of hosting provider impose limits on out going emails. Yes they still let you send emails and yes they give you a path to sendmail, but they only ley you send so many emails per minute or hour and they restrict the number of recipients in the BCC header.

Also, Subscribe2 follows the RFC2822 standards for email header formatting, some MTAs don’t follow it as strictly and this is where other problems arise.

Given the huge variety of hosting solutions (different web servers, web platforms, mail agents, blog setups and hosting limitations) you first port of call for failed emails (total or partial) should be your hosting provider.

They have access to your web log files and they should be able to tell you where and why your emails are being blocked. Armed with this information you will most probably be able to fix the issue or at least provide me with enough information to point you in the right direction!

As a footnote, I use Subscribe2 on my main blog site for work. I am now on VPS hosting because shared hosting repeatedly failed to send emails for my site due to anti-SPAM restrictions. Now I’m on VPS it works flawlessley without any edits to the Subscribe2 code.

47 thoughts on “Troubleshooting Failed emails

  1. Hi – I have S2 v 3.4 on WP 2.2

    How can I set the time of day for daily digest emails to be delivered? At the moment it is delivering at random times. IE 10.29pm one day and 3.35pm the next.

    Thanks.

  2. Roz,

    Subscribe2 links into a pseudo-cron function built into the WordPress core files. It’s pseudo cron as it relies upon visits to your site to fire off the script – this may be why you are seeing the email sent at various times.

    The only way to get around this is to use CRON on the server but this is not available to the majority of WordPress users and those who do have access should be capable of altering the script for their own needs.

  3. Is there any way to hack this to use the To: field and not the BCC: field? I want to send to a separate mailing list, but Mailman bounces anything with an implicit destination and the listserve address in the BCC.

    Help!

  4. Dave,

    I’d suggest that you try to only have one recipient per email if you are going to do this otherwise all your subscribers will be able to see each others email addresses.

    Look in the code for the Mail() function, block comment out the code that constructs the BCC header and replace it with something like:

    foreach ($recipients as $recipient) {
    $recipient = trim($recipient);
    if (!is_email($recipient)) { continue; }
    @wp_mail($recipient, $subject, $mailtext, $headers);
    }

  5. Greets:
    I am testing out Subscribe2 3.5 on WordPress 2.2.

    I ran a test by subscribing on the subscribe page I’ve created. I got a message telling me to check my mail. A confirmation message was there. Clicking on the link, though, instantly displayed my WordPress subdirectory in my web browser!

    Now I have attempted to install the software before, and thought that I have deleted all of the files from the old version prior to the new. I see that when I go into Options, some stuff I’ve written was still there. I think I tried changing the subscribe2 file, but not sure if I have to toss that one.

    Also, I created a WordPress directory inside my web root (public_html/wordpress), but moved the main index.php for WordPress outside the WordPress folder but inside the web root directory (public_html/index.php). I think I tried getting assistance for dealing with this, but wasn’t able to at the time and hope that someone will know what I need to do.

    In any event, any assistance to make the plugin a go would be appreciated. Thanks!

    Velanche

  6. Velanche,

    The link generated consists of your blog URL and then a “?s2=” followed by a whole bunch of numbers. Your URL is probably pointing to where you have put index.php as you have moved this file to the root.

    Try adding /index.php before the “s2=” in the link. If that works hand edit the code on line 495 from:

    $link = get_settings(‘siteurl’) . “?s2=”;

    To:

    $link = get_settings(‘siteurl’) . “/index.php?s2=”;

  7. S2 2.3.5 on WP 2.2 has stopped reliably sending mail for me; only a handful of my subscribers get notified.

    I have two questions. First, can I tell by examining the wp_options MySQL table whether S2 is configured correctly? Specifically, where should I look for the digest options, and what are the valid values?

    Also, I checked with the host, and it seems that there’s an entry in the logs for an email that went out OK, but I suspect lots of addresses were left out of the BCC header. I was thinking I might define my own version of wp_mail() that would write out a copy of the email that would be sent to a file. Is this a smart idea, or a stupid one? (If it’s a smart one, maybe S2 should include such a wp_mail for debugging purposes.)

  8. Hey thanks for the info; it works now!

    I’m gonna play around with it for a bit. I have other questions, but they will come soon. Need to seek more documentation on what can be done. Thanks again!

  9. Jack,

    If you suspect that some addresses are being clipped from the BCC header then make use of the BCCLIMIT setting. It will ensure that only the defined number of recipients are included in each header.

    As for the debugging with wp_mail() – this is possible but is a duplication of the server log files. also, I’m struggling to put much time in to coding at the momentšŸ˜¦

  10. What about my wp_options question? How are the S2 settings encoded there, esp. the digest setting?

  11. Jack,

    The Subscribe2 values are stored as an array. The digest emails are sent using the WordPress inbuilt cron system so there are any number of valid settings as defined in the WordPress core and any other plugins that hook into cron_schedules.

    You might need to take a look at the add_weekly_sched function in the Subscribe2 code and add some lines to print the array to the screen to see the valid options you have.

  12. Hi!

    I was finally able to get the subscribe2 service up and running on our server after our administrator allowed email sending on our root server. I thought all was great. Subscription notifications were sending, per post emails being sent out…then we decided to switch to the per-weekly email digest.

    Unfortunately I cannot get the per-anytime function to work correctly. I thought maybe it was trying to send out too many emails or something to do with the BCC stuff. To test that theory out I ‘unconfirmed’ everyone except a test email I’ve been using. It sent out the per-post email like before, but still does not send out a per-hourly email. Do you have any clue as to where I should look for the problem?

    Thanks, and I appreciate the plugin. It will be awesome if we can get the per-weekly digest working.

  13. Matt,

    The CRON functions are described as pseudo-cron because they happen almost periodically. They require someone to be access your site and fully loading a web page to work correctly. This could be your problem if your site is low traffic.

    I have a very low traffic site that uses CRON to fire a backup plugin – tese backups arrive at all ties of the day despite being set to occur once per day at midnight.

  14. I can confirm that altering instances of @wp_mail() to @mail() in the subscribe2.php file fixes the problems I was having with mail delivery failures. My install is now sending out mails successfully with no other alterations to the code.

    This might be worth adding this as a fix for other people to try as it seems to be more due to alterations in the WP core than a server issue.

  15. We’ve had over 5,500 page views since the page’s inception on June 22. If you’re interested, it’s wireeagle.auburn.edu . I don’t believe a lack of page views is our problem.

    The email function does work. I can send out emails to the subscribers. I haven’t tested more than a few since we have about 20 and I don’t want to be using subscribers as testers. It’s just when it is set to run at a certain time or per week that it doesn’t send the email out. I looked at the apache logs, and there’s no indication that any errors are showing up because of it.

  16. Sorry for the delay in answering. I just got back from a mission trip to Malawi, Africa on Friday. I installed and tested the DB-Backup plugin, and it works fine. It sends backup email to me hourly, so obviously the cron job is running. Does that narrow it down to some email setting on our side?

  17. Matt,

    It certainly sounds like the CRON functions are being called. That does narrow things down to the plugin or email.

    As the plugin works on other systems using the CRON function we should look into your email sending. Are you on a host or your own server? Have you checked into the email logs?

  18. I’m on a host. I’m getting our admins to check out the logs for me this afternoon. Hopefully I’ll have more information tomorrow. Thanks for you help so far!

  19. Well, there’s a new development. To test the email feature I just added a couple of addresses. One is a hotmail address I have for the purpose of testing. The only two addresses I sent a test to were my gmail account that was subscribed back in June and the recently added hotmail address. The only one that received an email was the gmail account. This same thing happened when I tried to add a couple of our server administrators. They said that they did not receive and email, and the email logs only show it being sent to my gmail account, not them or the hotmail account. It’s not sending emails to the newly subscribed addresses.

  20. Matt,

    How did you add the new addresses? Public or regsitered. Did you confirm them if public? Did they subscribe to all categories if registered?

    For debugging purposes you may want to change the BCC: header to a CC: header so you can see a list of recipients.

  21. I registered them through subscribe2 as public. I went through and changed all references to @wp_mail to @mail, and now it does send to all the email addresses. Question: If I have it set to hourly digest and I haven’t made any posts in the hour, should it still send out the hourly digest, or does it only send out a digest when a post has been made in that given time?

  22. Ok, thanks. I changed the digest to daily instead of hourly this time and added a line in subscribe2.php where the cron job fires to email me when the psudo cron job executes. I’m hoping for some strange reason that the daily digest will work if the hourly isn’t. At least this time I’ll know if the cron is being executed. I’ll let you know how it goes (it isn’t supposed to send till about 4 pm cst).

  23. Well, I guess the cron job never even fired because I never received an email. Any idea why the cron would work for the backup utility but not for subscribe2?

  24. Matt,

    Where in the cron function did you put the command to mail direct to you? Was it right at the start of the function?

    I can only think of a few causes for what you are seeing.

    1/ Subscribe2 is not set for digest emails in your options page so the Subscribe2 cron function is not being called at all.
    2/ The command to email you was after a bail out command that evaluated as true (for example there were no new posts).
    3/ The emails were in fact sent but blocked on the server for some reason.

  25. Ah! I think I may have found the problem finally. At first I was only putting the test email at the end. After your suggestion I added it to three different places – Once at the beginning, once after the recipients were combined, and once at the end. As expected, I received the first two emails. This was a little strange since our admin reported no emails being sent at all before this.

    To get the mailing to work in the first place, I had to replace every “@wp_mail” with “@mail” as described on another page here. The line that is supposed to email in the cron function originally was: this->wp_mail and now was this->mail . I believe that was the problem. I think it was trying to run the mail function but not finding it defined because of the “this” keyword. I changed it simply to call the php defined mail function without the “this” keyword. This is my last theory at least. I’ll know if I’m correct at 5:05 pm. And I will rejoice if I’m right!

  26. Finally!!!! Hooray!

    I was right in a way, but wrong. It wasn’t the “this” keyword that was wrong. It was changing it from this->wp_mail to this->mail. I changed it back to this->wp_mail and now the digests work. That was a goof on my part. Thanks so much for your help though. It certainly lead me in the right direction. AWESOME plugin!

  27. Subscribe2 (3.7) is sending out erratic emails. Initially it was sending me emails whenever someone subscribed. However, suddenly it has stopped sending me those emails. When I check the dashboard I do see several new subscribers.
    What can possibly go wrong?

  28. Sudipta,

    Sounds to me like your emails are being blocked. If they were being sent but aren’t arriving now, then unless you’ve changed something in the code it’ll be something on the server.

    Contact your host and ask them to review the email logs to tell you what’s going on.

  29. Alright, I think I’ve figured out why my emails aren’t going out–I’m using WordPress 2.2.3

    I finally realized that everything in the section “Excluded Categories” was checked. The problem is, there’s no text, just the boxes and a ton of empty space. No big, I unchecked everything, but when I save and it says my options have been saved, I look and the boxes are all checked again….any idea what kind of craziness is going on here?

  30. I’m developing a blog with the Subscribe2 plugin and I run into the problem that no e-mails are being sent. I dug into the code and added on some key places a mail command which sents an email to my address with the line number where the command is send from.

    After receiving messages it seems the script doesn’t excecute the mail funtion after the line with: “if ( (empty($recipients)) || (” == $message) ) { return; }”. So i figured out this function isn’t receiving any recipients.

    I took a look at the last lines of the function publish and changed the recipients var with my own address and the message is being sent and I received it in my mailbox.

    But now the big question, why does “$this->mail($this->get_registered(“cats=$post_cats_string&format=html”), $subject, $body, ‘html’);” not work?

  31. DJLorenzo,

    The most likely reason that the line you’ve pasted isn’t working is because you have no registered subscribers who have opted to get HTML emails as their notifications. I presume that the other lines starting $this->mail are working as expected?

  32. I wish I could level a comment under the post of BCC Header Troubleshooting. That is why I leave a comment here.

    You are right that the reason why only the first recipient can receive the email because the parsing problem. It is not from your code or the php mail function. Instead, the problem comes from one of the files in WordPress called class-phpmailer.php which alters the constructed header from your code. Since the bcc header contains multiple lines. The class-phpmailer stores each line as a header. A bcc header will then become multiple headers. Therefore, only the first recipient can the email.

    Since it is quite hard to explain, let me give you an example (just the bcc header):

    Say there are 3 subscribers in the bcc list. Your code will generate this:
    Bcc: subscriber1@domain1.com
    subscriber2@domain2.com
    subscriber3@domain3.com

    All three subscribers should be able to receive the email provided that the header remains the same.

    However, class-phpmailer.php alters the bcc header to be like this:
    Bcc: subscriber1@domain1.com
    subscriber2@domain2.com:
    subscriber3@domain3.com:

    When the mail is sent, the mail server will think the last two lines (email addresses) are the headers with empty values. Obviously they are not and are ignored. Thus, only the first subscriber can receive email.

  33. does anyone every get this message?

    MySQL server has gone away

    it is part of this

    WordPress database error: [MySQL server has gone away]
    SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN (‘category’) ORDER BY t.name ASC

    WordPress database error: [MySQL server has gone away]
    SELECT COUNT(id) FROM wp_subscribe2 WHERE active=’1′

    WordPress database error: [MySQL server has gone away]
    SELECT COUNT(id) FROM wp_subscribe2 WHERE active=’0′

    WordPress database error: [MySQL server has gone away]
    SELECT COUNT(meta_key) FROM wp_usermeta WHERE meta_key=’s2_subscribed’

    Thoughts? I was able to send out one successful admin email, generating that error, and have been unable to send after that one attempt.

  34. Jrodjared,

    This is because the time out on your SQL server application is too low or something is closing the connection before the queries have chance to finish. Check your configuration or ask your host.

  35. I had your plugin working fine, but then my hosting service tightened up the system to thwart spammers. All the emails were then rejected by local scanning code saying “Relaying not permitted”. All the WordPress messages still get through using @wp_mail. I tried changing your code to use that instead of @mail, but now I get nothing; not even the error messages. Any thoughts on how I can fix this?

  36. Ted,

    Your host should be able to help you solve this better than me but the error message you are getting would lead me to believe that your emails are coming from an email address that is on a different domain to that of your site. Try changing the email address of the admin account that sends the emails.

  37. Hi. Wonderful tool and a real pleasure to use. I look forward to contributing in reflection of the value I’m getting from your tool in building a local community of interest in our town.

    I’m using Subscribe2 to send out emails on posting of new content to both registered and confirmed users. I recently added a new category, and then new content that was categorized only under than one new category. Emails went out only to registered users, and no alerts (synopsis of new content with link to the item on the blog) went out to no one. I can’t find anything on the site or in the documentation or tool that helps me understand what I’ve failed to do. The one thing that seems closest is to run the routine that resets the categories to which emails are sent for what is referred to as “registered users” and in doing so, to include the new category– I’ve tried that and will see next time I add new content under this category whether it works. It seems this literally doesn’t apply, because it refers to registered users and I’m trying to set up for confirmed users. What am I missing here. Thanks again.

  38. Alan,

    Any Confirmed subscribers should have got a notification. Registered users may not have done unless they had opted to be “Automatically Subscribe to new categories”.

    The Bulk Management section in Manage->Subscribers allows you, as admin, to subscribe all Registered users to a selection of categories defined by you. This action cannot be reversed except by individual users changing their settings.

  39. Thanks for the great plugin. One issue I seem to have is whenever I change submit settings in the admin it pushes back the weekly digest to one week after the current blog time. I tried changing the
    date shown after “last_s2cron” in the options entry, but it has no effect. In another comment I saw that you suggested changing the time in the database. Is there a way to change the suscribe2 wp_options entry so I can reschedule the weekly digest?

    Thanks!

  40. Keston,

    That shouldn’t happen unless you check the box to reset the cron time – I’ll look into it.

    [Update]

    Whoops, having looked into it I’ve made some changes to remove the check box and missed adding a line – it’ll be fixed in the next version or the current dev version if this is a big problem for you!

  41. can someone email me at normanbenecke@gmail.com to provide me with help…. I have tried everything and it is only sending to the registered users but not the subscribers…

    I can let you loggin to my wordpress and take a look if you know what is going on… my host just told me to talk to wordpress about the problem when I asked them to investigate….

  42. Normy B

    Your host are really bad then if they won’t even look into this for you – I’d suggest you leave and find someone who will offer you some support!

Comments are closed.