We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2320
    • 47 Posts
    Hi,
    I must be stupid because I can’t figure it out. I have a eform that works perfectly
    [!eForm? &formid=`contactForm` &subject=`hello` &report=`contactreport` &tpl=`contactform` &automessage=`email` &gotoid=`16` &vericode=`0`!]
    

    But not &automessage. May be I’m wrong I didn’t find any example on that but I have a chunk called email and I want to send this as an email to the sender. Nothing heppens. Am I missing something or using the wrong thing to do it?
    Thanks for your help.
    Chris
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Are you sure you have the name of the chunk exactly as it’s named (upper case, lower case)?
      chunk name (non-numeric) or document id (numeric) to use as an auto-responder message Can include [+form fields+]. E.g. [+firstname+] - tags: [form_fields],[postdate] - note: eForm will send the auto-respond message to the email address specified inside the [email] form field
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 2320
        • 47 Posts
        Yes sure 100%. I thought that maybe the fact that I called my chunk email might be a problem so I renamed it all lowercase and used the same in my eform call. The chunk is a html email, so I added &allowhtml=`1` just in case. I also tried to get the latest phpmailer class which makes eform doesn’t send anything at all. The only thing that doesn’t work is the automessage. I tried also to put an id of a document to see if it makes a difference but nope. I don’t know how to debug that or just try to use something else to send an email to the sender.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Hm. Maybe it needs a &from and &fromname set, although it should default to your site’s default email address (set in the Configuration, User tab), looking over the code the &automessage parameter gets loaded into a variable $autotext in the snippet code
          'autotext' => isset($automessage)? $automessage:""


          which gets checked for document ID or chunk or snippet
          if($autotext) $autotext = (($tmp=efLoadTemplate($autotext))!==false )?$tmp:$_lang['ef_no_doc'] . " '$autotext'";
          

          ...
          $tpl = ( $doc=$modx->getChunk($key) )? $doc : false;
          ...
          


          Then it gets merged for any placeholders, and mailed
          $isHtml = ($sendAsText==1 || strstr($sendAsText,'autotext'))?false:true;
          if ($autotext && $fields['email']!='') {
          	$autotext = formMerge($autotext,$fields);
          	$mail = new PHPMailer();
          	$mail->IsMail();
          	$mail->CharSet = $modx->config['modx_charset'];
          	$mail->IsHTML($isHtml);
          	$mail->From		= ($autosender)? $autosender:$from;
          	$mail->FromName	= ($autoSenderName)?$autoSenderName:$fromname;
          	$mail->Subject	= $subject;
          	$mail->Body		= $autotext;
          	AddAddressToMailer($mail,"to",$fields['email']);
          	if(!$mail->send()) return 'AutoText: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo;
          
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 2320
            • 47 Posts
            I added the from and fromname and it just send the email with that info but doesn’t send the automessage chunk. To make sure I’m not misunderstanding the whole thing &report sends an email to me with the info on the form and &automessage sends the content of the chunk/id/snippet to the email put in the form. Is it correct? I’m on testing mode so I fill the form with my email to make sure I receive the report and the automessage which I don’t. Is it a problem to have them sent to the same email...maybe? I don’t know what I’m doing wrong at that point.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              It should go here
              AddAddressToMailer($mail,"to",$fields['email']);

              so it should go to whatever address was put in the "email" form field.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 2320
                • 47 Posts
                Does the field’s name needs to be ’email" to work. That’s what I have:

                <input type="text" value="" id="cf_email" name="cf_email" eform="Email Address:email:1">
                  • 2320
                  • 47 Posts
                  I tried on every modx sites that I have an none works with %automessage. I can’t be the only one with that problem or I really don’t know how to use it but the doc is not really giving any example. Any idea on how to go around that? another snippet, or add something to manually send the response. My only problem though is how to send the email to the sender, how do I send the email variable to another snippet that would do that...I’m super lost right now.
                  Thank you for your time though.
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    The field name does need to be "email".

                    Otherwise, you could use eForm’s event onBeforeMailSent (or whatever it’s called, I forget exactly) and use the snippet’s function to set the $fields[’email’] value to your $fields[’cf_email’] value.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 2320
                      • 47 Posts
                      well, apparently yes the name of the field needs to be email. I tried to change it to email and I receive the automessage. Weird.