I think it’s a bug.
The code should use the system setting emailsender
, if the fiarFrom
property is not set.
But because there is a default property set with the property fiarFrom
set to an empty string, this doesn’t work.
So either the following line in the code has to be change
* fiarRequired Optional. If set to false, the FormItAutoResponder hook doesn't stop
* when the field defined in 'fiarToField' is left empty. Defaults to true.
*
* @param array $fields An array of cleaned POST fields
*
* @return bool True if email was successfully sent.
*/
public function process($fields = [])
{
$tpl = $this->modx->getOption('fiarTpl', $this->formit->config, 'fiDefaultFiarTpl', true);
$mailFrom = $this->modx->getOption('fiarFrom', $this->formit->config, $this->modx->getOption('emailsender'));
$mailFromName = $this->modx->getOption('fiarFromName', $this->formit->config, $this->modx->getOption('site_name'));
$mailSender = $this->modx->getOption('fiarSender', $this->formit->config, $this->modx->getOption('emailsender'));
$mailSubject = $this->modx->getOption('fiarSubject', $this->formit->config, '[[++site_name]] Auto-Responder');
$mailSubject = str_replace(
array('[[++site_name]]', '[[++emailsender]]'),
array($this->modx->getOption('site_name'), $this->modx->getOption('emailsender')),
$mailSubject
);
$fiarFiles = $this->modx->getOption('fiarFiles', $this->formit->config, false);
$isHtml = $this->modx->getOption('fiarHtml', $this->formit->config, true);
to
$mailFrom = $this->modx->getOption('fiarFrom', $this->formit->config, $this->modx->getOption('emailsender'), true);
or the empty values have to be deleted from the default property set .
You already had the same problem in January:
Using formit and Akismet in a Modx 2.8.3 environment, I can’t get the autoresponder to work. This is my form header:
[[!FormIt?
&hooks=`Akismet,FormItAutoResponder,email`
&fiarTpl=`my-tpl`
&fiarSubject=`Foo subject`
&fiarToField=`mail`
&fiarReplyTo=`...`
&emailTpl=`mail-tpl`
&emailTo=`...`
&emailSubject=`foo subject`
&emailFrom=`...`
&akismetType=`contact-form`
&akismetAuthor=`name`
&akismetAuthorEmail=`mail`
&akismetContent=`text`
&akismetHoney…
There is already an issue on Github, but unfortunately it hasn’t been fixed yet.
opened 11:48PM - 03 Jan 23 UTC
## Bug report
Around line 75 of the Autoresponder file, the `getOption()` ca… lls for `$mailFrom`, `$mailSender`, and `$mailFromName` should have `true` as a final argument so they'll take the default value if they exist in the properties but are empty.
Without this change, the emails can fail to be sent.