We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49659
    • 86 Posts
    I have the following setup for a 'Contact Us' form:

    [[!FormIt?
        &hooks=`recaptchav2,spam,email,redirect,FormItAutoResponder`
        &emailTpl=`EmailTpl`
        &emailTo=`[email protected]`
        &emailSubject=`'Contact Us' inquiry: [[+category]]`
        &fiarTpl=`AutoResponseTpl`
        &fiarSubject=`Thank You for Contacting Us`
        &fiarToField=`email`
        &fiarFromName=`My Company`
        &fiarFrom=`[email protected]`
        &redirectTo=`23`
        &store=`1`
        &validate=`nospam:blank,
          category:required,
          name:required,
          email:email:required,
          comment:required:stripTags`
        &vTextRequired=`Enter a value for this field`
        &category.vTextRequired=`Select a category`
        &name.vTextRequired=`Enter your name`
        &email.vTextRequired=`Enter your email address`
        &email.vTextEmailInvalid=`Enter a valid email address`
        &comment.vTextRequired=`Enter your comment or question`
        &validationErrorMessage=`<div class="val-error-hdr">
            <a href="[[~22]]" class="btn float-right">Reset form</a>
            <h3>Please review the following errors:</h3>
            <ul>
                [[+errors]]
            </ul>
            </div>`
    ]]
    [[!+fi.validation_error_message]]
    
    <h1 class="form-header">How May We Help You?</h1>
    <form action="[[~[[*id]]]]" id="form-contact" method="post">
    ...
    


    With this configuration, the recaptcha, email and autoresponse works fine, but it does not redirect. If I remove the FormItAutoResponder parameter, then redirect starts working.

    Somehow, FormItAutoResponder is aborting the redirect before it can complete.

    I have tried positioning FormItAutoResponder before the 'redirect' parameter, and it still stops the redirect from happening.

    Any ideas on how to troubleshoot this?

    Thanks in advance..

    Karl
      • 38783
      • 571 Posts
      I'm see you have tried swapping the sequence of events around, and I may have misunderstood what you have tried, so apologies if this is what you have already done.

      Does it work if you put redirect at the end, both in the &hooks line and when specifying where to redirect to with the &redirectTo=`23` as in the sample here:
      https://docs.modx.com/extras/revo/formit/FormIt.FormItRetriever

      [[!FormIt?
          &hooks=`recaptchav2,spam,email,FormItAutoResponder,redirect`
          &emailTpl=`EmailTpl`
          &emailTo=`[email protected]`
          &emailSubject=`'Contact Us' inquiry: [[+category]]`
          &fiarTpl=`AutoResponseTpl`
          &fiarSubject=`Thank You for Contacting Us`
          &fiarToField=`email`
          &fiarFromName=`My Company`
          &fiarFrom=`[email protected]`
          &store=`1`
          &validate=`nospam:blank,
            category:required,
            name:required,
            email:email:required,
            comment:required:stripTags`
          &vTextRequired=`Enter a value for this field`
          &category.vTextRequired=`Select a category`
          &name.vTextRequired=`Enter your name`
          &email.vTextRequired=`Enter your email address`
          &email.vTextEmailInvalid=`Enter a valid email address`
          &comment.vTextRequired=`Enter your comment or question`
          &validationErrorMessage=`<div class="val-error-hdr">
              <a href="[[~22]]" class="btn float-right">Reset form</a>
              <h3>Please review the following errors:</h3>
              <ul>
                  [[+errors]]
              </ul>
              </div>`
          &redirectTo=`23`]]
      
        If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

        email: [email protected] | website: https://andytough.com
        • 49659
        • 86 Posts
        Quote from: andytough at Mar 15, 2018, 08:17 PM
        I'm see you have tried swapping the sequence of events around, and I may have misunderstood what you have tried, so apologies if this is what you have already done.

        Does it work if you put redirect at the end, both in the &hooks line and when specifying where to redirect to with the &redirectTo=`23` as in the sample here: ...

        It was worth a try, but no joy.

        I set the hooks order to:
        &hooks=`recaptchav2,spam,email,FormItAutoResponder,redirect`


        ..and moved the
        &redirectTo=`23`
        to the end.

        There is a lot going on here (recaptchav2,spam,email,FormItAutoResponder,redirect), and the presence of FormItAutoResponder in the list still seems to prevent redirection from occurring.
        • If FormItAutoresponder returns false, the error should be logged according to the code. Any errors in the MODX error log?
            • 49659
            • 86 Posts
            Quote from: Jako at Mar 15, 2018, 11:35 PM
            If FormItAutoresponder returns false, the error should be logged according to the code. Any errors in the MODX error log?

            Right. Should have done that sooner. This error occurs every time I submit the form with FormItAutoresponder enabled:

            [2018-03-15 15:40:46] (ERROR @ /paas/c0205/www/core/cache/includes/elements/modsnippet
            /3.include.cache.php : 145) [FormIt] An error occurred while trying to send the auto-responder 
            email: SMTP Error: data not accepted.SMTP server error: DATA END command failed

            Any ideas how to fix that DATA END error?

            I just did another test using QuickEmailCheck, and the resulting report looks good, at least as far as I can tell. Maybe someone with more chops in this area can see something amiss?
            2018-03-16 00:33:45	SERVER -> CLIENT: 220-ld149.smtpserver_goes_here.com ESMTP Exim 4.89_1 #1 Thu, 15 Mar 2018 17:33:45 -0700 
                               	                  220-We do not authorize the use of this system to transport unsolicited, 
                               	                  220 and/or bulk e-mail.
            2018-03-16 00:33:45	CLIENT -> SERVER: EHLO c0205.paas1.tx.modxcloud.com
            2018-03-16 00:33:45	SERVER -> CLIENT: 250-ld149.smtpserver_goes_here.com Hello paas1.tx.modxcloud.com [173.193.182.146]
                               	                  250-SIZE 52428800
                               	                  250-8BITMIME
                               	                  250-PIPELINING
                               	                  250-AUTH PLAIN LOGIN
                               	                  250-CHUNKING
                               	                  250 HELP
            2018-03-16 00:33:45	CLIENT -> SERVER: AUTH LOGIN
            2018-03-16 00:33:45	SERVER -> CLIENT: 334 VXNlcm5hbWU6
            2018-03-16 00:33:45	CLIENT -> SERVER: a2FybEB6dXJpbnN0aXR1dGUuY29t
            2018-03-16 00:33:45	SERVER -> CLIENT: 334 UGFzc3dvcmQ6
            2018-03-16 00:33:45	CLIENT -> SERVER: WTg+NyRKTT1MPw==
            2018-03-16 00:33:45	SERVER -> CLIENT: 235 Authentication succeeded
            2018-03-16 00:33:45	CLIENT -> SERVER: MAIL FROM:
            2018-03-16 00:33:45	SERVER -> CLIENT: 250 OK
            2018-03-16 00:33:45	CLIENT -> SERVER: RCPT TO:
            2018-03-16 00:33:45	SERVER -> CLIENT: 250 Accepted
            2018-03-16 00:33:45	CLIENT -> SERVER: DATA
            2018-03-16 00:33:45	SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
            2018-03-16 00:33:45	CLIENT -> SERVER: Date: Thu, 15 Mar 2018 19:33:45 -0500
            2018-03-16 00:33:45	CLIENT -> SERVER: To: "[email protected]" 
            2018-03-16 00:33:45	CLIENT -> SERVER: From: QuickEmail 
            2018-03-16 00:33:45	CLIENT -> SERVER: Reply-To: [email protected]
            2018-03-16 00:33:45	CLIENT -> SERVER: Subject: Default Subject
            2018-03-16 00:33:45	CLIENT -> SERVER: Message-ID: <[email protected]>
            2018-03-16 00:33:45	CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.21 (https://github.com/PHPMailer/PHPMailer)
            2018-03-16 00:33:45	CLIENT -> SERVER: MIME-Version: 1.0
            2018-03-16 00:33:45	CLIENT -> SERVER: Content-Type: text/html; charset=UTF-8
            2018-03-16 00:33:45	CLIENT -> SERVER:
            2018-03-16 00:33:45	CLIENT -> SERVER: Default Message
            2018-03-16 00:33:45	CLIENT -> SERVER:
            2018-03-16 00:33:45	CLIENT -> SERVER: .
            2018-03-16 00:33:50	SERVER -> CLIENT: 250 OK id=1ewdJZ-002kZB-Qh
            2018-03-16 00:33:50	CLIENT -> SERVER: QUIT
            2018-03-16 00:33:51	SERVER -> CLIENT: 221 ld149.smtpserver_goes_here.com closing connection
            
              • 3749
              • 24,544 Posts
              When a hook fails, the hooks after it in the list don't execute.

              One possible cause is having a from email address for the autoresponder that is not authorized to send from your server (i.e., no mail account with that email address).

              Some other ideas here: https://www.google.com/search?q=SMTP+server+error%3A+DATA+END+command+failed&oq=SMTP+server+error%3A+DATA+END+command+failed
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 49659
                • 86 Posts
                Quote from: BobRay at Mar 16, 2018, 02:50 AM
                When a hook fails, the hooks after it in the list don't execute.

                One possible cause is having a from email address for the autoresponder that is not authorized to send from your server (i.e., no mail account with that email address).

                Some other ideas here: https://www.google.com/search?q=SMTP+server+error%3A+DATA+END+command+failed&oq=SMTP+server+error%3A+DATA+END+command+failed

                Thanks Bob.

                I made the two email addresses in these MODX System Settings the same:

                • emailsender
                • mail_smtp_user

                Still no joy. This email address IS authorized to send and receive via the SMTP server set in the MODX settings value: mail_smtp_hosts

                One thing to note - the autoresponder does not fail. It sends an autoresponse just fine. But it also causes the redirect to fail. Without the autoresponder enabled, the redirect works fine.

                Karl Forsyth
                  • 3749
                  • 24,544 Posts
                  Some of the people at the link I gave also had the email sent successfully, even though PhpMailer crashed as it did for you.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 38783
                    • 571 Posts
                    Does adding &fiarReplyTo help?

                    &fiarFrom=`[email protected]`
                    &fiarReplyTo=`[email protected]`


                    Looking at the report from SMTP test it looks like you are logging in to the server using the address kjf@. Perhaps if Formit Auto Responder does not specify a ReplyTo then the system sends kjf@ as the reply to. This would cause a mismatch between the sender and the replay to which could cause the error you are seeing.

                    If this does not help could you post all your code so that we can see if there is a problem in any of your templates or forms?

                    This would include the contents of &emailTpl=`EmailTpl`, &fiarTpl=`AutoResponseTpl` the form and the code on resource id 23



                    [ed. note: andytough last edited this post 6 years ago.]
                      If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

                      email: [email protected] | website: https://andytough.com
                      • 3749
                      • 24,544 Posts
                      @Andy - It's okay for the sender and reply-to not to match. In fact it's pretty much required that they not match for a contact form where the email the user supplies is the reply to (so you can respond), but the from/sender must be an email authorized to send email from the server.
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting