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

    This snippet is exactly what I was looking for. However, for some strange reason Modx (or I) can’t save the "Sendtoafriend 0.2" snippet (Note: the chunks and "addpopuplink" snippet can be saved).

    After setting up the "Sendtoafriend" snippet I hit the save button: what I get is an "error on page" message in the statusbar and Modx shows the index.php in the mainwindow. The snippet isn’t listed in the resource list.... huh

    I tested this with two different websites, but without succes. What am I doing wrong?

    Thanks
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      probably an issue with "mod_security" on your web server. They usually don’t like anything in the POST that looks like email stuff, and of course this snippet will be full of email stuff. (usually "cc" and "bcc" causes the problems)
        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
        • 16732
        • 592 Posts
        Strange

        In agreement with susan, try to save the snippet after having removed these lines :

        $entetedate = date("D, j M Y H:i:s -0600");
        $entetemail = "From: $email_exp \n";
        $entetemail .= "Cc: ";
        $entetemail .= " \n";
        $entetemail .= "Bcc: \n";
        $entetemail .= "Reply-To: $email_exp \n";
        $entetemail .= "X-Mailer: PHP/" . phpversion() . "\n" ;
        $entetemail .= "Content-Type: text/html;charset=iso-8859-1"."\n" ;
        $entetemail .= "Date: $entetedate";

          • 13481
          • 97 Posts
          Good Snippet - feels pretty beta at this point but does the job with some work.

          If you need a quick fix for the HTTP_REFERER problem, then here is what I did:

          $myForm = str_replace("[+message+]", $defaultFormText.str_replace('http//','http://',$_SERVER['HTTP_REFERER']), $myForm);


          Would be nice to have some email injection checking (sorry if there is some, I didn’t see it in my look over of the code), and captcha protection. Would also be nice to have the default language be english, or have an english version.

          Thanks for writing this one smiley

          James
            • 16732
            • 592 Posts
            Thanks for your fix James.

            I maide this snippet just to explore MODx capacities and your are right it need to have some additions.
              • 18094
              • 1 Posts
              Hi,

              thanks for the snippet. It’s working great.

              I just have two questions on it:

              1. Is it possible to make the url in the email into a link?

              2. I’m not using a Pop-Up window for the form. Instead it is openend in the same window.
              After the Form is submitted, I redirect the user to a thank you page.
              Can I somehow put a link to the previous page (which is the same as the link sent to the friend) on the thank you page?
                • 19645
                • 23 Posts
                I have a few websites running with modx and sendtoafriend snippet. Recently, I installed a new one and here the snippet doesn’t send email, actually.
                When I hit the submit button, I get the ok message, but no message will be received. Is there a way to debug this? This website is on server, running in safe mode, while the others are not.
                  • 15877
                  • 55 Posts
                  I am having problems getting Sentoafriend to work with IE.

                  First, Addpopuplink generates a script error (only tested in IE 7).

                  To avoid this, I used a classic window.open script to open the popup. It works normally in Firefox, but in IE (6 or 7), I cannot get the URL of the page to display in the message field.

                  I changed
                  $myForm = str_replace("[+message+]", $formtext.$_SERVER[’HTTP_REFERER’], $myForm);
                  to
                  $myForm = str_replace("[+message+]", $formtext.str_replace(’http//’,’http://’,$_SERVER[’HTTP_REFERER’]), $myForm);

                  but it does not help.

                  Anybody has had the same problem and solved it?
                    • 15877
                    • 55 Posts
                    I have delved a bit into the problem and found out that the method you use to retrieve the previous URL does not work in IE.
                    (meaning that all previous users only tested it under non IE browsers huh)

                    $_SERVER[’HTTP_REFERER’] fails under internet explorer

                    I am trying to do the following:
                    set a cookie with the full URL in all pages (except the sendtoafriend one)
                    $id = $modx->documentIdentifier;
                    $myurl= $modx->makeUrl($id, ’’, ’’, ’full’);
                    setcookie (’url’, $myurl, time() + (60*60*24));

                    retrieve it in Sendtoafriend.

                    So far, no luck. The cookie disappears when the popup opens.
                      • 16732
                      • 592 Posts
                      Hi kilroy,

                      I don’t support any more this snippet ... I’m working on an eForm base version.