How can we configure the email plugin so that the person that filled out the form is set as reply_to? At present the fields "email from" and "email to" in plugin set up are the same (let us say: [email protected]), but this way the sender looks the same as the receiver and I can't use the "reply" option.
I found this chunk of code:
TWIG
process:
- email:
from: "{{form.value.email}}"
to: "{{config.plugins.email.to1}}"
reply_to: "{{form.value.email}}"
subject: "Contact by {{form.value.name|e}}"
body: "{%include ‘forms/data.html.twig’ %}"
My contact form (the same as the the "simple form" of GRAV documentation) includes also the google captcha, but if I include the code above in my contact.md file, the captcha are no longer working...
Can someone provide me with a corrected code?
Thanks a lot!
two questions which are actually overlapping each other: if I configure my contact.md file adding the code, the google captcha are not working properly. Probably is my fault, because at present the "captcha: true" condition is immediately after "process:" and I don't know if the chunk of code email:
TWIG
from: "{{form.value.email}}"
to: "{{config.plugins.email.to1}}"
reply_to: "{{form.value.email}}"
subject: "Contact by {{form.value.name|e}}"
body: "{%include ‘forms/data.html.twig’ %}"
must be included before or after the "captcha: true" code.
---title:'Contact Form'form:name:contactfields:name:label:Nameplaceholder:'Enter your name'autocomplete:'on'type:textvalidate:required:trueemail:label:Emailplaceholder:'Enter your email address'type:emailvalidate:required:truemessage:label:Messageplaceholder:'Enter your message'type:textareavalidate:required:trueg-recaptcha-response:label:Captchatype:captcharecaptcha_not_validated:'Captcha not valid!'buttons:submit:type:submitvalue:Submitreset:type:resetvalue:Resetprocess:captcha:truesave:fileprefix:contact-dateformat:Ymd-His-uextension:txtbody:'{% include ''forms/data.txt.twig'' %}'email:subject:'[Site Contact Form] {{ form.value.name|e }}'body:'{% include ''forms/data.html.twig'' %}'message:'Thank you for getting in touch!'display:thankyou---
I wonder where I can paste the chunk of code I wrote in my first post...I suppose immediately after process: but if I do this , the captcha are not correctly processed
Any help would be appreciated!!
Ok! After a lot of tries this is the code which works correctly. Please note I use Helium and Gantry 5 for GRAV- I'm not sure if this code is suitable for other Grav themes.
YAML
title:'Contact Form'form:fields:name:type:textlabel:Namevalidate:required:truemessage:Please enter your name!email:type:textlabel:Emailvalidate:type:emailrequired:truemessage:Please enter your email address!subject:type:textlabel:Subjectvalidate:required:truemessage:Please enter a subject for your message!message:type:textarealabel:Messagevalidate:required:truemin:10message:Email message needs to be more than 10 characters long!g-recaptcha-response:type:captchalabel:Captchavalidate:required:truerecaptcha_not_validated:'Captcha not valid!'buttons:submit:type:submitvalue:Send Emailprocess:captcha:trueemail:from:"{{ form.value.email }}"to:"{{ config.plugins.email.to }}"subject:"[Contact] {{ form.value.subject|raw }}"body:"{{ form.value.message }}<br /><br />{{ form.value.name }}<br />{{ form.value.email }}"message:'Thank you from contacting us!'display:thankyou