plain-solutions-gmbh / kirby-form-block-suite

This form plugin for Kirby offers you maximum flexibility and usability. It can be used as a block anywhere you needed. This repository replaces the obsolete version 2.0.
Other
38 stars 12 forks source link

Error sending notification emails if no email field #55

Closed purplespider closed 2 months ago

purplespider commented 3 months ago

It seems that if you want to use the "Send notification" option to send the submissions to the website owner, the form must have an email field, otherwise an error ("You need at least one field that is use for an email.") will occur. However, this requirement shouldn't really be necessary.

I have a website with a "Request a Callback" form, it asks for Name and Phone number, and I'd like submissions sent to the website owner, but I can't currently do this, as it errors unless I also put a required Email field on the form.

It seems the reason it requires an email field to set the "replyTo" header of the email, so if there isn't an email field, could this header just be omitted to allow the email to still be sent?

plain-solutions-gmbh commented 3 months ago

Thank you for your valuable input.

The notify_reply message was missing.

It makes sense that if notify_reply has not been set, notify_from should be used. Therefore, I have made a change in the code, which can be found in version 3.4.1.

purplespider commented 3 months ago

Thanks for looking at this so quickly!

However, I'm getting an error when trying to send on 3.4.1

In my config I have:

'microman.formblock' => [
    'from_email' => ["info@example.com" => "My Website"],
],

And now, on 3.4.1, when trying to submit a form, it says: "Error sending notification: "My Website" is not a valid email address"

Seems to be related to this change.

plain-solutions-gmbh commented 3 months ago

I see the problem. Check Version 4.3.2...

purplespider commented 3 months ago

Thanks, that does sort it, however, I've noticed that this approach forces you to manually specify notify_reply which means it isn't possible to have an optional email field that is still used for the "reply to" address if it is filled in.

It would be nice if the fallback for notify_reply could be your existing getEmail() method, which automatically hunts out any existing email fields.

Something like this, perhaps: https://github.com/plain-solutions-gmbh/kirby-form-block-suite/pull/56

plain-solutions-gmbh commented 2 months ago

Looks good. Thanks for your PR. Please send me a email for a free kirby form block license for your effort. kirby@micorman.ch