We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29181
    • 480 Posts
    Hi,
    I would like to use cc so that whoever has filled in my form and sent it off, can see that it has in fact gone.

    The layout of the report I’m sending with the eForm call however could be confusing to whoever receives it. Is there a way for me to send the person just a simple report saying something like:

    Thank you [+name+] for your feedback. Your mail has been sent and our offices will take a look just as soon as the kettle has boiled...providing we are sober..and here of course.

    Where as the office gets all the information so the client can process it and do whatever the client does with it?

    Any help would be much appreciated.

    Taff
      Adrian Lawley: www.adrianlawley.com
      • 30223
      • 1,010 Posts
      You can do this by using the eFormOnMailSent event and something like the following function. Have a read through eForm’s documentation on how to work with it’s events.

      //<?php
      function onMailSentFunction(&$fields){
         global $modx;
         //you have no access to the eform parameters here
         //so you'll have to hardcode most things in this function
         //There's no error checking so if things go wrong here
         //you won't notice. Errors are ignored
      
         //load extra report chunk
         $extraReportChunk = 'clientEmailReport';  
         $mailReport = efLoadTemplate($extraReportChunk);
      
         if( $mailReport ){
            //merge placeholders
            $mailReport = formMerge($mailReport,$fields);
            
            //create and send mail   
            $mail = new PHPMailer();
            $mail->IsMail();
            $mail->CharSet = $modx->config['modx_charset'];
            $mail->IsHTML(true);
            $mail->From      = '[email protected]';
            $mail->FromName  = 'ME';
            $mail->Subject   = 'Thank you for your feedback';
            $mail->Body      = $mailReport;
            //set to address to email input field
            AddAddressToMailer($mail,"to",$fields['email']);
            $mail->send();
         }//end if mailTemplate
         
         //return to eForm
         return true;
      }
      //?>
      
        • 29181
        • 480 Posts
        Works a treat,

        thanks!

        Taff
          Adrian Lawley: www.adrianlawley.com
          • 34017
          • 898 Posts
          I was looking for this.

          Thanks Toby,
          Chuck
            Chuck the Trukk
            ProWebscape.com :: Nashville-WebDesign.com
            - - - - - - - -
            What are TV's? Here's some info below.
            http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
            http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
            • 37550 ☆ A M B ☆
            • 711 Posts
            onesmarthost Reply #5, 19 years ago
            Hi,

            Ive just tried to use this and after the form is submitted I just get a blank screen, when I comment out the line

            $mail = new PHPMailer();

            The result page loads ok.

            my snippet call is:


            [[rsvp_online]]
            [[GuestResponse2db]]
            [[eForm? &formid=`rsvp_guest_response` &tpl=`guest_response` &noemail=`1` &eFormOnBeforeFormParse=`onBeforeParseFunction` &protectSubmit=`0` &eFormOnBeforeMailSent=`GuestResponse2db` &submitLimit=`0` &to=`[email protected]` &subject=`Thanks for the RSVP` &report=`rsvp_guest_thanks`]]

            function GuestResponse2db( &$fields )
            	{
            global $modx;
            $extraReportChunk = 'rsvp_response4customer';  
            $mailReport = efLoadTemplate($extraReportChunk);
            $mail = new PHPMailer(); <-- if i comment this out i don't get a blank page. 
            return true;
            }
            
            


            Do you think it’s something to do with my setup?

            Cheers
              http://www.onesmarthost.co.uk
              UK MODX Hosting with love.
              • 11975
              • 2,542 Posts
              Hi,

              you could check first if the class is defined

              if(!class_exists(’PHPMailer’)){
              //and if not include the file.
              include(...);
              }
              $mail = new PHPMailer();


              :-)
                Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                • 37550 ☆ A M B ☆
                • 711 Posts
                onesmarthost Reply #7, 19 years ago
                As easy as that laugh

                Cheers for the help.

                Aaron.
                  http://www.onesmarthost.co.uk
                  UK MODX Hosting with love.
                  • 30223
                  • 1,010 Posts
                  Since you want to send two emails it would have helped to not disable emailing in the first place &noemail=`1`. With this you’re telling eForm not to bother with emails and consequently eForm will not include the phpmailer class. Set &noemail to 0 and you won;lt need the extra check in your function.

                    • 37550 ☆ A M B ☆
                    • 711 Posts
                    onesmarthost Reply #9, 19 years ago
                    Hi Toby,

                    Initally I did have &noemail=`0` and still ended up with the blank page, doing the extra check seems to work for now.

                    Thanks

                    Aaron
                      http://www.onesmarthost.co.uk
                      UK MODX Hosting with love.
                      • 25124
                      • 54 Posts
                      I’m having a problem with this. I’m populating the db OK and receving the customers feedback form to my main email address however the customer is not getting a simple reply email to acknowledge they have filled out the form and their email address was correct.

                      Using Modx 0.9.6 and eForm - 1.4.4

                      What I’m trying to achieve is to get the email "from address" to be the person who filled out the form with their name as the "sender" & to populate the db .... (<-- this is all working) - but to also send them (the person who filled out the form) an email that comes from the sites main email address saying thanks for filling out the form (I could send them a copy of what I get easily but I don’t think it would look right sending them an email from their own address - problems with replying, etc.)

                      So the form page is working and I’ve added the eFormOnMailSent function, called onMailSent2Cust. I’ve even transposed the line $extraReportChunk = ’clientEmailReport’; to $extraReportChunk = ’eFeedbackReport’; incase I misunderstoon the merge part. Which, incidentally hasn’t made any difference. So here I am without the customers getting a confirmation mail, but I get one and the db is being populated. Arrrrgggghh.

                      On my form page
                      [!eForm2db!] [!eForm? &formid=`eFeedBackForm` &eFormOnBeforeMailSent=`eForm2db` &tpl=`eFeedBackForm` &thankyou=`eFeedBackThanks` &submitLimit=`0` &protectSubmit=`0` &subject=`Feedback request from [[ipaddress]]` &report=`eFeedbackReport` &fromname=`[+name+]` &from=`[+email+]` eFormOnMailSent=`onMailSent2Cust`!] 


                      [[onMailSent2Cust]] contains
                      <?php
                      function onMailSent2Cust(&$fields){
                         global $modx;
                         //you have no access to the eform parameters here
                         //so you'll have to hardcode most things in this function
                         //There's no error checking so if things go wrong here
                         //you won't notice. Errors are ignored
                      
                         //load extra report chunk
                         $extraReportChunk = 'clientEmailReport';  
                         $mailReport = efLoadTemplate($extraReportChunk);
                      
                         if( $mailReport ){
                            //merge placeholders
                            $mailReport = formMerge($mailReport,$fields);
                            
                            //create and send mail   
                            $mail = new PHPMailer();
                            $mail->IsMail();
                            $mail->CharSet = $modx->config['modx_charset'];
                            $mail->IsHTML(true);
                            $mail->From      = '[email protected]';
                            $mail->FromName  = 'Syyy Ltd';
                            $mail->Subject   = 'Thank you for your feedback';
                            $mail->Body      = $mailReport;
                            //set to address to email input field
                            AddAddressToMailer($mail,"to",$fields['email']);
                            $mail->send();
                         }//end if mailTemplate
                         
                         //return to eForm
                         return true;
                      }
                      ?>


                      {{clientEmailReport}} contains
                      <p>Thanks for filling out the form on the Syyy website. </p>
                      <p>As you have received this you should have no problems receiving our quote or any further information you may have requested</p>




                      Any ideas on this?