Error Sending Email

This topic contains 4 replies, has 3 voices, and was last updated by  Troy Wolf 2 years, 3 months ago.

  • Author
    Posts
  • #10524

    Matt Deuel
    Participant

    Love your plugin! Used it for an event a few months back and am returning to set-up a new event. Everything seems to be in order, except that when someone registers it give an “Error Sending Email” message right below the “You have been signed up message.” I’ve done a few test sign ups with different names, emails, and browsers all getting the same result. After checking inboxes, no confirmation emails have been sent to volunteers. No emails are being sent to their Event Chair either. Any thoughts/direction? Thank you!

  • #10526

    Stephen Sherrard
    Keymaster

    I’m certain I just answered this same exact question from someone else a month or two ago, but can’t find where that was. Lots of answers to similar questions about email issues on the WordPress.org support forum for the sign-up sheets plugin, though.

    Since it’s nowhere on this forum yet, I’ll put my comments here for future referral.

    That particular “Error Sending Email” message is created by my plugin ONLY when it receives an error response from the WordPress email function.

    In other words, my plugin creates all the necessary info for the email (from, to, reply, cc/bcc, subject, and text), formatting according to the WordPress codex guidelines, and then it uses the WordPress wp_mail function to actually send the email:

    https://developer.wordpress.org/reference/functions/wp_mail/

    If that function returns a value of false, it means that there was a problem sending the email. So, if you are seeing that error message, it means either something is wrong with the WordPress wp_mail function (not likely, unless some files are corrupted on your server), or something is not configured properly on your server for the PHP sendmail function (which is what the WordPress wp_mail function uses by default).

    I have found on some servers, they don’t like the way CC or BCC addresses are formatted by my plugins (especially if there is more than one email in the BCC field), even though I’m formatting them exactly the way that the WordPress codex specifies. Not much I can do about that. The only way to do it differently would be to loop through every CC or BCC email and send a separate email out for each one, instead of trying to include all the addresses in one CC or BCC field. Not an efficient way to do things, but I had to do that for a custom development project for someone else since their sever simply wouldn’t accept multiple emails in the BCC field, no matter how I formatted them.

    Also, note that if you are using the standard WordPress method of sending emails, you are sending through the PHP sendmail script, almost always as user “nobody” (which is how PHP scripts are normally run on most servers). However, perhaps with a security update, your server was set to NOT allow emails to be sent by user “nobody”, effectively making the default PHP sendmail method useless unless you are able to configure it to send as the account owner instead of nobody. There are also some email clients that are more likely to mark messages as spam if they come from these “nobody” type of users. So, you also have a lower chance of delivery.

    The BEST way to avoid ALL of the above issues is to install a plugin that takes over the wp_mail function and sends emails through a real SMTP account instead. I do this for ALL of my own web sites, as its MUCH more reliable and I also get a copy in my “sent” folder for my email account (I use Google business email for ALL my sites).

    My new favorite plugin for this is Postman SMTP:
    https://wordpress.org/plugins/postman-smtp/

    You should definitely look into setting that up on your WordPress site and connecting it to a SMTP email account (set up a dedicated email address on your server for your WordPress site if you don’t want to use a personal email address).

    Other than that, there is not much more I can do as my plugin is simply reporting that WordPress generated an error when it tried to send the email, meaning the email did NOT get sent.

  • #10530

    Matt Deuel
    Participant

    Stephen,

    Thank you for your very thoughtful and detailed response. I truly appreciate the time you’ve taken to explain this. At first pass, I’m having some trouble with Postman-SMTP… but I trust that is something I’m doing wrong. I’ll go thru their documentation and figure it out. Thank you for the help and recommendation.

    Thank you!
    Matt

  • #13358

    Stephen Sherrard
    Keymaster

    Also, note that in case it is the formatting of the BCC fields giving your server problems sending emails, in version 1.13.0 I added options to send emails 1 at a time instead of using BCC:

    New option added in Email Settings to send all CC/BCC emails as separate TO emails, potentially bypassing issues on some servers that do not like the default formatting of multiple CC/BCC emails in the header when using default server Sendmail (wp_mail) function, as opposed to bypassing Sendmail by using an SMTP plugin to send all WordPress emails via SMTP (much more reliable)

  • #14148

    Troy Wolf
    Participant

    In hopes it is helpful for folks, I got tired of quirky issues around sending email that almost always were caused by issues with my own server. I either had an SMTP misconfiguration or needed to add SPF records to my DNS to prevent getting black-listed, yada, yada, yada. On top of that, when mail failed, it was like a black-hole with no logs to look at….because I didn’t know how to properly configure everything in the server nor where to look.

    Now I use the Mailgun service (http://www.mailgun.com). No I don’t work for them. I am using their SMTP on several client sites including WordPress sites now. Mail sending with Mailgun is extremely fast and they have a sweet dashboard you can log into to see your mail logs. If mail fails, you’ll know why! This has been worth gold when clients tell me, “the website never sent me the confirmation”. I can go into my Mailgun account and see the SMTP traffic and their mail server’s receipt of the message.

    The service is free for up to 10,000 messages per month…which I come nowhere near hitting.

    To use an SMTP server (instead of your own local WP server), you need to install a plugin to do SMTP. I use this free one: http://www.callum-macdonald.com/code/wp-mail-smtp/

You must be logged in to reply to this topic.