Auto Responder Not Working

OK, I’ve used Auto Responder a hundred times. But I cannot determine why it’s not working on this form.

At one point I was getting an invalid fiar email address. The senders email address was called ‘email2’. I changed that to ‘email’ and the error went away but still no auto responder is being sent.

I added &emailCC=email but that is not being deliver either.

The value of the email address IS appearing in the email sent to the client.

The redirect is working so the autoresponder hook isn’t failing completely.

I’m stuck.

Here’s the form.

> [[!FormIt? 
> &hooks=`recaptchav2,email,FormItSaveForm,FormItAutoResponder,redirect`
> 
> &fiarTpl=`emailcc`
> &fiarToField=`email`
> &fiarSubject=`companyname`
> &fiarFrom=`info@companyname.com`
> &fiarFromName=`[[++site_name]]`
> &fiarReplyTo=`companyname.com`
> &fiarReplyToName=`companyname`
> 
> 
> &emailTpl=`email-sendto` 
> &emailTo=`name@gmail.com`
> &emailFrom=`info@companyname.com`
> &emailFromName=`companyname`
> &emailSubject=`companyname Contact Form`
> 
> &emailCC=`email`
> 
> &redirectTo=`40` 
> &validate=`firstname:required,email:email:required,location:blank`
> ]]
> 
> 
> <div id="form_container" class="clearfix">
> 
> <form class="form" action="[[~[[*id]]]]" method="post">

> 
>  <label for="email">Email: <span class="error">[[!+fi.error.email]]</span> </label><br /> 
>   <input id="email" type="text" name="email" value="[[!+fi.email]]" /> <br /> 
> 
...rest of the form
> 
> </form>
> </div>

Is this set to a valid email address?

Hey Bob

Yes it is. I sanitized the client info a bit inaccurately.

&fiarReplyTo=info@xxxgroup.com

I don’t see anything else that looks wrong.

Usually, the &fiarFrom value needs to be for a user who has an email account at the server with the right to send mail.

Since the redirect is working, the AutoResponder is definitely completing and return true.

If you use an anti-spam service like Akismet, that could be a factor.

You might take a look at this.

The only other thing I can suggest is going into the Autoresponder code and adding some debugging statements that write values to the MODX error log like this:

$msg = 'ReplyTo: ' .  $emailReplyTo;
$this->modx->log(modX::LOG_LEVEL_ERROR, $msg);

The code is in this file: core/components/formit/src/FormIt/Hook/Autoresponder.php

Bob

We’re not using Aksimet.

Usually, the &fiarFrom value needs to be for a user who has an email account at the server with the right to send mail.

The client has it’s own email server MS 365. That account is a valid email account that they use to receive submissions. I assume it can also send, but I’m confirming that.

Where in the Autoresponder.php does the debug code go? I tried putting it right after the ? at the top of the file. That caused an error msg.

Thanks Bob.

The code would go inside the curly braces of any of the functions, which look like this:

public function somefunction() {
    /* debugging code somewhere in here */
}

If displaying a variable’s value, the code must be below where its value is set.

Try this first: FormIt and the hooks class should produce their own error messages. I don’t use FormIt and the error placeholders aren’t very well documented. Try taking out the redirect hook and adding these placeholders to the page with the form:

<h3>Errors</h3>
<br>Validation: [[!+fi.validationErrorMessage]]
<br>General: [[!+fi.errors]]
<br>Hooks: [[!fiar.errors]]
<br>Hook: [[!fiar.error]]
<br>General: [[+error]]
<br>General: [[+errors]]

Here’s another thought. Make sure QuickEmail is installed, and on another page, try this:

[[!QuickEmail?
&emailsender=your sending address
]]

Bob

I put the placeholders below the form on the page and sent a message. There were no values displayed at all.

I installed quickmail with my email address and viewed the page. It said send reported successful, but I did not receive an email.

I put the debug code on line 38 inside the {}. When I submit a form I get a 500 error page.

public function __construct($hook, array $config = array())
{
    $msg = 'ReplyTo: ' .  $emailReplyTo;
    $this->modx->log(modX::LOG_LEVEL_ERROR, $msg);
    
    $this->hook =& $hook;
    $this->formit =& $hook->formit;
    $this->modx = $hook->formit->modx;
    $this->config = array_merge($this->config, $config);
}

The results with QuickEmail and the error placeholders suggests that it’s something to do with the host/server and not your code or MODX (though do check your spam folder for the QuickEmail message).

On the 500 error, you probably don’t want to be calling MODX services in a constructor. The variable you’re looking for is not set at that point anyway. Any other function should work, though signs point to a problem higher up in the system. Maybe the mail() function is disabled. Have you tried SMTP?