We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6726
    • 7,075 Posts
    Sorry I lost track of this thread but do anyone know if the email validation issue I had raised a while back is solved ? It’s a show stopper for me...
      .: COO - Commerce Guys - Community Driven Innovation :.


      MODx est l'outil id
      • 9130
      • 171 Posts
      Yes, the newer versions of TXNewsletters found on this thread use a different email validation regex so the email you mentioned should work. Unfortunately the newer regex seems to have its own set of bugs.
        • 5430
        • 247 Posts
        My host is limiting email traffic and I have a fairly large list. Can anyone here give me a clue as to how I might throttle the delivery speed (1 email per 5 seconds or so)? I’m using the PHPmail version of TXNewsletter that was posted in this thread. Any help would be...well....really helpful.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I don’t see a parameter option for this, so it looks like you would need to hack the txnewsletters.inc.php file (in the assets/modules/txnewsletters directory).

          At line 1516 you’ll find the function that actually sends the mail. This is done in a foreach() loop, so at the end of the loop you would need to add a delay function.

          Here’s one way, using the PHP sleep() function (not tested!)
            function sendNewsletterMail ($emails,$emailFrom,$newsletterId,$subject) {
              global $modx;
                    
              $html = sendHTML($newsletterId);
          	include_once 'controls/modxmailer.inc.php';
              foreach ($emails as $id => $datas) {
                
                $email = $datas['val'];
                $timestamp = $datas['timestamp'];
                $MD5 = ControlMD5($email,$timestamp);
                $link = 'http://'.$_SERVER['HTTP_HOST'].$modx->config['base_url'].'index.php?&id='.$modx->TXNewsletters['idPageUnsubscribe'].'&action=del&email='.$email.'&control='.$MD5;
                $send_html = preg_replace('#(\{link_unsubscribe\})#', $link, $html);
                
                $headers  = 'From: ' . $emailFrom . "\n";
                $headers .= 'To: ' . $email . "\n";
                $headers .= 'Return-Path: ' . $emailFrom . "\n";
                $headers .= 'MIME-Version: 1.0' ."\n";
                
                $headers .= 'Content-Type: text/html; charset=UTF-8' ."\n";
                $headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
                $headers .= $send_html . "\n";
          
          // Send with PHPMailer
          	  $mail = new MODxMailer();
          	  $mail->IsMail();
                $mail->IsHTML(true);
                $mail->From = $emailFrom;
                $mail->FromName = $modx->config['site_name'];
                $mail->Subject = $subject;
                $mail->Body = $send_html;
                $mail->AddAddress($email);
          	  if (!$mail->send()){
          			echo $mail->ErrorInfo,'<br />';
          	  } else {
          		  $result = true;
          	  }
          	  // time-delay function
          	  sleep(60*5); // will delay 5 minutes - sleep works with seconds
              }
              return $result;
            }
          
          
            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
            • 15163
            • 7 Posts
            Hi all,

            I would like to have a form for subsribers to change/update their info. Cant seem to find any instructions to do that. Does anyone have a clue please?

            Thanks

            Jon
              • 5430
              • 247 Posts
              Thanks Sottwell. It works for the first few names, but it errors out after about 20 minutes and I’ve got about 7500 names on the list so at 500/hr (my host’s limit) I’m out of luck without some significant adjustments, which I really don’t want to mess with. I’m going to take a look at your Dada implementation and see if that might be a better direction for me to go, TXnewsletters seems a bit unfinished at the moment. Sounds like your experience with Dada has been pretty positive. I appreciate the help.
                • 5430
                • 247 Posts
                ...or perhaps I spoke too soon. Forgive me if this is an ignorant question, but is it possible for this script to run without a browser session open? It appears, based on autoreplies I received more than 12 hours after the session closed on me, that emails were still going out. Is that even possible or am I hoping in vain? Sotwell, your solution may indeed have worked if this is the case, but I’d like to know how I might adjust the script so that I can receive some form of notification when it’s finished, if indeed it finished.
                  • 32025
                  • 305 Posts
                  My installation has come to a halt. I stuck am on the last instruction for step 4.

                  This step:
                  - in module dependencies tab, add " TXNewsletters " snippet dependancy to share params with

                  In the modules dependencies tab I click: Manage Dependencies. Next I click: Add snipplet a pop up comes up and this is the message inside:
                  A possible CSRF attempt was detected. No referer was provided by the server.


                  So it won’t let me attach the dependency!

                  I did notice one thing when pasting the code into the snipplet and module. In the snipplet the php code was already in the field
                  <?php
                  ?>

                  And in the module it was not (and it didn’t add it) Do I leave the php tags above for both the module and the snipplet, or go without by copying the exact code given?

                  Any help would be much appreciated.
                    Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
                    • 26931
                    • 2,314 Posts
                    hi wbbuilder,

                    the module code should not be wrapped in <?php ?>, but the Snippet code should ( therefore it’s prefilled )

                    A possible CSRF attempt was detected. No referer was provided by the server.
                    you can disable it: tools -> configuration -> site -> Validate HTTP_REFERER headers? -> no
                    if it’s already disabled, you probably need to try another browser ( in case you use FF ) or/and have a look at this http://www.belafontecode.com/fix-modx-csrf-error-in-firefox/
                      • 32025
                      • 305 Posts
                      Thanks sharkbait it was the http header setting that enabled this to work.

                      Now I have another problem it’s this step:
                      6/ now you should create modx documents / template for newsletters and subscription pages, something like following :

                      + newsletters (directory)
                      | + newsletter 1 (page) // with a newsletter template
                      | + newsletter 2 (page) // with a newsletter template
                      + newsletter subscription (page) // with subscribe template

                      => newsletter template should have "{link_unsubscribe}" added in an link, something like this : "<a href="{link_unsubscribe}">click here for unsubcribe</a>"
                      the tag "{link_unsubscribe}" will be replaced with an encoded unsubscribe link by the module before sending

                      => subscribe template page should have this snippet call "" to generate subscribe form
                      if you choose to have a different page for unsubscribe, the template page should have this snippet call ""
                      I create a directory called: newsletters (id=18), then sub-directories called: Newsletter Template (id=20), and Subscribe (id=19).

                      In the newsletter directory I have this: [[TXNewsletters]]
                      In the Newsletter Template (subdirectory) I have this: "<a href="{link_unsubscribe}">click here for unsubcribe</a>"


                      [[TXNewsletters]]

                      In the subscribe page I have this: ""

                      Now in my module configuration I have these settings:
                      Sending email: MyEMAIL@ADDRESS
                      Newsletter Directory: 20
                      Item per page: 15
                      Page Subscribe: 19
                      Page Unsubscribe: 19

                      When I preview any of the template pages, there are no forms showing. The only thing that shows is the unsubscribe link in the Newsletter Template Page.

                      Where do I get these template or get them to show? I did not add any css styles to my stylesheet yet.



                        Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/