• Resolved jakalx

    (@jakalx)


    I have installed the ‘Volunteer Sign Up Sheet’ plugin into my wordpress site (version 6.3) today and upon trying to sign up, I receive an ‘ERROR SENDING EMAIL’ message. My wordpress is hosted on Azure, so it might have something to do with that, but I was able to create a fix in the mean time by inserting the php code ‘$to = $signup->email’ onto line 77 in the send_email() function located in the class-pta_sus_email.php file. For whatever reason, trying to set the ‘To’ email string value to a format like ‘John Doe <[email protected]>’ blows up trying to send an email, but just sending the email address for the value works fine. I can’t attach images to this post, but let me know if you want me to send the screenshots I took which somewhat further explains the error I was encountering. Thank you for taking the time to make this plugin, as I am finding it very useful for my PTO website!

    • This topic was modified 1 year ago by jakalx.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jakalx

    (@jakalx)

    Actually, I can add images. I’m new to interacting with the wordpress interface. Below are some links to the images which further explains what I was encountering. Thanks!

    https://ibb.co/grhjqz7
    https://ibb.co/Zh1KsvT

    Plugin Author DBAR Productions

    (@dbar-productions)

    Thanks for the detailed post.

    That’s not really a “bug” with my plugin, but, rather, an issue with whatever plugin you are using to replace the WordPress email function with the function that uses Azure to send your emails. You may want to contact the developers of that plugin and let them know that their code won’t accept “to” addresses that are formatted that way, as that’s a pretty standard way (RFC 2822 standards) of formatting to addresses. I set up the formats to comply with what the wp_mail function accepts and expects… See this page on the wp_mail function and the “Valid Address Formats” section:
    https://developer.www.ads-software.com/reference/functions/wp_mail/

    When you use something like an SMTP email plugin, or a plugin to connect with a specific email service (such as Azure), then that plugin REPLACES the WordPress wp_mail function with its own wp_mail function (that’s how many WordPress functions were designed, so that they could be replaced/extended by other plugins). So, when my plugin calls wp_mail to send the emails, instead of now using the standard wp_mail function, your other plugin is substituting its own version of wp_mail so it can connect to the Azure mail servers. Nothing I can do about that in my own plugin as there is no easy way for me to figure out that another plugin has decided to replace the wp_mail function with its own function that is obviously not 100% compatible with the original wp_mail function.

    Also, there’s another way for you to modify the “to” address that my plugin uses without having to directly modify the code (since you will lose your changes if you update my plugin when I release a new version). If you notice in that first screenshot you sent (the code editor where you added some code), line 83 on your code editor shows the filter hook I added to allow other plugins to modify the $to address variable before the wp_mail function is called (there are hooks to modify many things in my plugin). You could write a very small code snippet to hook into that filter hook, take the passed in $to variable, parse it to extract just the email from between the < and > characters, and return just that part as the return variable, and that would fix things with your Azure plugin. If you aren’t sure how to do that, you can do some internet searching on how to use WordPress filter hooks to modify things with your own code snippets, and you’ll find a ton of resources.

    Of course the preferred way would be to let whoever made the Azure plugin know that they are not accepting valid email formats that WordPress itself accepts.

    Plugin Author DBAR Productions

    (@dbar-productions)

    Actually, since the $signup is passed in with other variables in my filter hook, you don’t even have to parse the $to variable, you can just return the $signup->email
    the way you changed it in your simple modification.

    So, an example code snippet (not tested) would look like this:

    add_filter('pta_sus_email_recipient', 'ssp_replace_to_email_for_azure',10, 7);
    function ssp_replace_to_email_for_azure($to, $signup, $task, $sheet, $reminder, $clear, $reschedule) {
    	return $signup->email;
    }

    You would put that in your child theme’s functions.php file (assuming you are using a child theme so you don’t have to modify the parent theme). Or, if your theme has an area for custom code snippets, use that. Or, use a code snippet plugin that allows you to create custom code snippets and put it there.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘ERROR SENDING EMAIL message when user is signing up’ is closed to new replies.