Formit not using the fiarFrom mail address in the sentEmailTpl mail

Summary

I’m using a Formit form and it’s working fine except for one thing. In the &fiarFrom hook I specified a mail address with the domain name in it (i.e. website is domain.com, &fiarFrom is noreply@domain.com).

One would except that ‘noreply@domain.com’ is the From mail address in the confirmation mail that is sent to yourself (set in &emailTpl). Instead, the user’s filled in mailadres (user@sample.com) is set as the From mail address.

This is causing the incoming mails to go to the quarantaine map (they switched to Office365, which has a pretty strict spam handling protocol).

Why does it not take that mail address set in the &fiarFrom hook?

Here’s the code:

[[!FormIt?
&hooks=`recaptchav3,datestamp_submitted,spam,email,redirect,FormItAutoResponder`
&emailTpl=`form-sentEmailTpl`
&fiarToField=`email`
&fiarFrom=`noreply@domain.com`
]]

<label for="email" class="col-sm-3 control-label">E-mailadres: </label>
<input type="email" id="email" name="email" class="email form-control" 
value="[[!+fi.email]]" /> [[!+fi.error.email]]

I wonder if the problem could be that both the hook and field are called ‘email’?

Are you sure it’s the AutoResponder mail that is wrong (hook “FormItAutoResponder” → sent to customer) and not the “email” hook (the email usually sent to yourself)?

It seems to me that you are just missing the &emailFrom property for the “email” hook.
For this mail FormIt takes the value from the email field <input name="email" ... /> as the sender (if such a field exists). Which is rarely the desired behaviour.

It’s not the autoresponder mail: that is showing the noreply@domain.com nicely. It’s the emailTpl hook (mail to self) that is showing the user’s mail adress instead of noreply@

But you’re right: the &emailFrom was missing.

Like I said, use the additional property emailFrom.

&emailFrom=`noreply@domain.com`

The fiarFrom setting is only for the “FormItAutoResponder” hook.

Yeah, the @emailFrom was missing. It now looks like it’s working properly.

The thing I don’t understand is why it is not using the default mail from the system setting.

It does, if there is no emailFrom property and no form field with the name email.

I suppose this was once a good idea years ago. Now it can’t be changed without loosing backward compatibility.

So would it be better to change the for, to something like:

<label for="emailaddress" class="col-sm-3 control-label">E-mailadres: </label>
<input type="emailaddress" id="emailaddress" name="emailaddress" class="emailaddress form-control" 
value="[[!+fi.emailaddress]]" /> [[!+fi.error.emailaddress]]

Yes, renaming the email field is one possibility.

Another is to use the system setting tag in the “emailFrom” property:

&emailFrom=`[[++emailsender]]`

At least the type should remain “email”. :wink:

Thanks, this clarifies a lot

1 Like