We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7923
    • 4,213 Posts
    I tried the snippet and it seems that there’s nothing wrong with it. Called the snippet using [!Newsletter? &mode=`doc`!] and by going to the page, there was a list of documents that I had in modx. If selected "html" as the type to send, it sent the selected document source as html mail and by using "text" it also sent the source of the document but the content type of the mail was text/plain instead of text/html; charset=iso-8859-1..

    So all in all.. there’s something else going on with your installation Marschant. It’s the CURL that parses the document html for sending (and your’s seems to get just 1 instead of the page source), maybe there’s something wrong with your CURL module?

    Or maybe there is infact something wrong with the function that gets the selected documents source that affects some specific server enviroment. Here’s the function that is used, anyone notice anything that might cause errors?

    <?php
    
    	// Parser function to parse document page into html string
    	function parseWebPage($url) {
    		$ch = curl_init();
    		curl_setopt($ch, CURLOPT_URL, $url);
    		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    		$store = curl_exec ($ch);
    		$xml = curl_exec ($ch);
    		curl_close ($ch);
    		return $xml;
    	}
    
    ?>
    


      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
      • 37550 ☆ A M B ☆
      • 711 Posts
      Im also having problems with sending docs via this script, so far I have tested it with FURLs on and without both have the same effcts sad

      My setup is IIS6, PHP with Curl installed as a test I created a test page which writes a webpage to a file on the server this worked fine, the problem appears in the function and seems to hang when trying to write the website content to a varible:

      $store = curl_exec ($ch);

      The script i tried on my server to write a page to a file on the server is as follows and this works fine:

      $ch = curl_init("http://www.spcs.eu/");
      $fp = fopen("example_homepage.txt", "w");

      curl_setopt($ch, CURLOPT_FILE, $fp);
      curl_setopt($ch, CURLOPT_HEADER, 0);

      curl_exec($ch);
      curl_close($ch);
      fclose($fp);

      Also this is the phpinfo from my server: http://www.spcs.eu/info.php

      Any help would be much appreicated.

      Thanks
      Aaron
        http://www.onesmarthost.co.uk
        UK MODX Hosting with love.
        • 37550 ☆ A M B ☆
        • 711 Posts
        Not sure if this has anything to do with this

        Curl is trying to access our webpage direct on the server www.spscs.eu the server sites behind a firewall and the external address is not resolvable because we host dns on the server and the public IP Address is 69.93.44.122.

        I have updated the URL in the function to point to www.google.co.uk for example and this works fine.

          http://www.onesmarthost.co.uk
          UK MODX Hosting with love.
          • 37550 ☆ A M B ☆
          • 711 Posts
          Hi,

          I managed to fix my firewall issue in the end just added a host entry in windows which said the website was locally. Not sure if thats the proper way but it’s working smiley smiley

          This script is great but i found when selecting to send a page in HTML the links would not work so i decided to try and fix this and came up with the following:

          Replace this function:

          function parseWebPage($url) {
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_URL, $url);
          curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
          $store = curl_exec ($ch);
          $xml = curl_exec ($ch);
          curl_close ($ch);
          return $xml;
          }

          With

          function parseWebPage($url,$siteurl) {
          $assets = ’"’ .$siteurl .’/assets/’;
          $spage = ’"’ .$siteurl;
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_URL, $url);
          curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
          $store = curl_exec ($ch);
          $xml = curl_exec ($ch);
          curl_close ($ch);
          $xml = str_replace(’"assets/’, $assets, $xml);
          $xml = str_replace(’"/assets/’, $assets, $xml);
          $xml = str_replace(’"index.php’, $spage, $xml);
          return $xml;
          }

          Now just update all the following lines which calls this function:

          $url = $modx->config[’site_url’].ltrim($modx->makeUrl($docid), ’/’);
          $webPageHtml = parseWebPage($url);

          to:

          $url = $modx->config[’site_url’].ltrim($modx->makeUrl($docid), ’/’);
          $siteurl = $modx->config["site_url"];
          $webPageHtml = parseWebPage($url,$siteurl);

          And thats it now you can send HTML emails and all the links / images / css will link correctly, now we just need to work out how to fix the text emails as mine at present is sending raw html.

          Phew!

          If anyone wants me to post my full newsletter ammended code just let me know.

          Aaron
            http://www.onesmarthost.co.uk
            UK MODX Hosting with love.
            • 25663 MODX Staff
            • 12,272 Posts
            Keep it up and there will be a wonderful solution for you to post your code into early next week. wink
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 27
              • 117 Posts
              Hi all

              Thanks to awardle, ive got my snippet working for me, but when another user (with full admin rights) logs in and tries to send a newsletter, they get
              You are not allowed to access this area!

              Ive deleted the page and created it while logged in as the other user and still only the original admin can see it.

              Any ideas what i might be doing wrong?

              Cheers

              0
                • 37550 ☆ A M B ☆
                • 711 Posts
                I think there might be a bug in the script, creating web users groups etc seems to have no effect our requirement is to allow anyone who has access to the /manager area to be able to send newsletter so ive amended the snippet until i get more time to work out what is going wrong.

                change:


                // Check user permission
                $allowAdmin = false;
                // -- Web Group Check
                $WebGroup = explode(’|’, $accessWeb);
                if($modx->isMemberOfWebGroup($WebGroup))
                $allowAdmin = true;
                // -- Manager Group Check
                if(isMemberOfMgrGroup($modx->documentIdentifier))
                $allowAdmin = true;

                to:


                // Check user permission
                $allowAdmin = false;
                // -- Web Group Check
                $WebGroup = explode(’|’, $accessWeb);
                if($modx->isMemberOfWebGroup($WebGroup))
                $allowAdmin = true;
                // -- Manager Group Check
                if(isMemberOfMgrGroup($modx->documentIdentifier))
                $allowAdmin = true;
                if ($_SESSION[’mgrValidated’]==1) {
                $allowAdmin = true;
                }

                Basically the last 3 lines check if the user is validated by the modx manager which means the user should be an admin etc.

                Its not the best fix, but works for us where we have no web users logging into the manager section. smiley
                  http://www.onesmarthost.co.uk
                  UK MODX Hosting with love.
                  • 32241
                  • 1,495 Posts
                  Quote from: 0ad at Jun 27, 2006, 06:16 AM

                  Thanks to awardle, ive got my snippet working for me, but when another user (with full admin rights) logs in and tries to send a newsletter, they get
                  You are not allowed to access this area!

                  I don’t think it’s a bug. The way how the permission is set based on the document. Whenever you create a new admin user, it needs to have access to the current document. So if you assign your document in a document group called group1, then you need to assign your admin user in a manager group that is being associated with document group1.
                    Wendy Novianto
                    [font=Verdana]PT DJAMOER Technology Media
                    [font=Verdana]Xituz Media
                    • 6726
                    • 7,075 Posts
                    A thought just occured to me : it would be nice to have the ability to define which document groups are to be included in the document list, wouldn’t it ?

                    Disregard that, it’s already built in smiley

                    // -- $docGroup
                    // -- -- Allowed document group to be emailed [name_doc_group | *] (default to *)
                    // -- -- * means every document group
                    // -- -- name_doc_group means any document group separated by coma (ex: docgroup1, docgroup2)


                    (Dumb me, I should have read the code more carefully !)
                      .: COO - Commerce Guys - Community Driven Innovation :.


                      MODx est l&#39;outil id
                      • 12652
                      • 228 Posts
                      Sorry to see that it doesn’t look like much action has happened here for awhile... hopefully development has been moving along and just this thread has gone a little quiet as this could be a huge asset.

                      I haven’t done much with this and still trying to figure some of it out.

                      But a couple questions based on the limited testing...

                      - the from field is being listed as [email protected]
                      should that be picking up an email address from somewhere or is there a way to set it... I was actually surprised that it didn’t get blocked by spam blockers, but either way, that just won’t be good for sending.

                      - also I have one member in my group that I sent the email to, which was received, but also received a Mail failure - no recipient addresses with the To: field listed as blank.

                      thanks for any assistance
                        | Identity Developments delivers SEO focused web design and web presence services
                        - it&#39;s not about websites, it&#39;s about your identity. |