We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30897
    • 311 Posts
    Hi,

    Sorry for my english... I’m french... shocked

    How to send an e-mail with eForm with as addresses of shipper the address recovered in the form ?

    I hope you understand my question... undecided
      TylerD - In MODx we trust
      [Derni
      • 30223
      • 1,010 Posts
      not entirely smiley but I’m guessing you mean how to set the FROM or REPLY-TO header.

      You can set these headers by using the &from, &fromname and/or the &replyto parameters. See the eForm documentation which you can find in the snippets/eform/docs/ folder. You can use placeholders in the parameters as for instance:

      [!eForm? &from=`[+fld_email+]` &fromname=`[+full_name+]`!]


      where ’fld_email’ and ’full_name’ are the name of input fields in your form.

      You can set the &replyto parameter directly to a field name like this:

      [!eForm? &replyto=`fld_email` !]


      A warning though. If you set the &from parameter like this it is advisable to hard-code the TO address! Otherwise there’s a good possibility that someone will abuse your form.. (If both the TO and the FROM address come from form input someone could send anyone an email pretending to be somebody else)


        • 30897
        • 311 Posts
        Thx... you understand my problem...

        How to do a php action on email field like this :

        str_replace("@", "=", $email_visiteur)


        Thx
          TylerD - In MODx we trust
          [Derni
          • 30223
          • 1,010 Posts
          Sorry, this time I’m at a loss.. What is it that you want to achieve?

          Do you want to do the replacement on the value from an email form field?
          If, so try eForm’s #FILTER rule.

          <input type='text' name='email_visiteur' value='' eform="Email::1::#FILTER #LIST @||=" />
          


          You may have a problem with the = though as eForm may see this as the separator for an attribute. Give it a try...

            • 30897
            • 311 Posts
            I want to do a form to register people on mailing list manage by ezmlm on my server... My server host give to me a php script to register people in the mailing list :

            <?php
            
            $email_visiteur = "email in the form";
            
            $to = "NOM_MAILING_LIST-subscribe-" . str_replace("@", "=", $email_visiteur) . "@domaine.tld";
            $subject = "inscription";
            $message = "inscription";
            $additional_headers = "From: <".$email_visiteur.">
            "."Reply-To:<".$email_visiteur.">
            ";
            mail($to , $subject, $message, $additional_headers);
            ?>


            Any idea for create a param with the email field where @ being replace by = huh

            Thx
              TylerD - In MODx we trust
              [Derni
              • 30223
              • 1,010 Posts
              Ok, forget what I said before about the #FILTER rule. Not applicable in this case.

              Hmm, as far as I can see there’s no solution without hacking eForm... Here’s a possible solution using the eFormOnBeforeMailSent event...


              Just before the line (394 in eform 1.4.2)
              <?php
              if(!$nomail){
              ?>
              

              Add these 2 lines to eform.inc.php
              <?php
              $to = formMerge($to,$fields);
              if( empty($to) ) $nomail=1;
              ?>
              


              Then in the onBeforeMailSent event you call this function:
              onBeforeMailSentFunction( &$fields ){
                  $fields['to'] = "NOM_MAILING_LIST-subscribe-" . str_replace("@", "=", $fields['email_visiteur']) . "@domaine.tld";
                  return true;
              }
              

              (oh yes,... I’ve assumed here that the form has a textbox called ’email_visiteur’. Change that in the line above to the name of your textbox.)

              The function is placed in a separate snippet which should be called in the same page and before the call to eForm. To get an idea on how to work with eform events look through eForm’s documentation and event examples.
                • 30897
                • 311 Posts
                Thanks... grin

                I have modified eform.inc.php.
                I have created a snippet called "eMailingListOVH" with the onBeforeMailSentFunction function.
                In my form page, I call the snippets like this :

                [[eMailingListOVH]]
                [!eForm? &formid=`FormListeDiffusion` &to=`[email protected]` &eformOnBeforeMailSent=`onBeforeMailSentFunction` &fromname=`` &from=`[+email+]` &tpl=`FormListeDiffusion` &replyto=`[+email+]` &report=`FormListeDiffusionReport` &thankyou=`FormListeDiffusionMerci` &vericode=`1` &subject=`Inscription ML`!]


                But, I don’t receive a mail at "NOM_MAILING_LIST-subscribe-" . str_replace("@", "=", $fields[’email_visiteur’]) . "@domaine.tld". I have make a test with printing result of function and the email for mailing list is OK... Any idea ?
                  TylerD - In MODx we trust
                  [Derni
                  • 30223
                  • 1,010 Posts
                  Try setting the &to parameter to [+to+] like so: (and set &debug=`1` to see the mail headers on successful submit while testing)

                  [[eMailingListOVH]]
                  [!eForm? &formid=`FormListeDiffusion` &to=`[+to+]` &eformOnBeforeMailSent=`onBeforeMailSentFunction` &fromname=`` &from=`[+email+]` &tpl=`FormListeDiffusion` &replyto=`[+email+]` &report=`FormListeDiffusionReport` &thankyou=`FormListeDiffusionMerci` &vericode=`1` &subject=`Inscription ML`!]


                    • 30897
                    • 311 Posts
                    Great... the script is working like I want... BIG THX grin
                      TylerD - In MODx we trust
                      [Derni