michelegiorgi / formality

Forms made simple (and cute). Designless, multistep, conversational, secure, all-in-one WordPress forms plugin.
https://formality.dev
GNU General Public License v3.0
96 stars 16 forks source link

Email notification failed because of CURL error on getting template - avoidable scenario? #27

Closed pshemek closed 3 years ago

pshemek commented 3 years ago

Hello!

I ran into problems with email notifications while developing on Local by Flywheel.

After investigation it occurred that the reason was in email_content() function, in the line where you're getting the template:

$response = wp_remote_get(plugin_dir_url(__DIR__) . "public/templates/notification.html");

Http request failed because of cURL error 60: SSL certificate problem: self signed certificate

As there are many scenarios where wp_remote_get() might fail, wouldn't it be reasonable just to fopen() the template file from the filesystem? Why to get it remotely from plugin's own files?

Also it would be nice to have the template replaceable or filterable.

Thanks for your work.

michelegiorgi commented 3 years ago

Hey @macemmek, Thanks for your feedback.. It's a good point!

Honestly this piece of code has almost 2 years, and I don't remember why I used wp_remote_get(). It's absolutely preferable to avoid this function in this context, like you said.

I have rewritten the entire function to include a new php template file, that you can also edit/replace by putting a notification-formality.php file inside your active theme's directory.

You can start from the new default template, that you can find in the new v1.3.4: https://github.com/michelegiorgi/formality/blob/master/public/templates/notification.php

Let me know if it's clear and thanks again for your suggestion Have a nice day!