On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Since modSwiftMailer did not have an auto-generated thread, this will have to suffice (unless moderators disagree).

    Check out modSwiftMailer in the MODX Extras repository.

    Any bug reports, feature requests and questions should and will be placed here. ;-)
      @MarkGHErnst

      Developer at Adwise Internetmarketing, the Netherlands.
    • Hi Mark

      Swiftmailer is excellent and working very nicely. However I want to add the Throttler plugin and am not really sure how to go about it. Having looked at the Swiftmailer site, I have the following (with a slight tweak to take into account the transport):

      //Rate limit to 100 emails per-minute
      $modx->mail->registerPlugin(new Swift_Plugins_ThrottlerPlugin(
        100, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE
      ));
      
      //Rate limit to 10MB per-minute
      $modx->mail->registerPlugin(new Swift_Plugins_ThrottlerPlugin(
        1024 * 1024 * 10, Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE
      ));


      Any assistance much appreciated.

      Rgds
      James
      • Hey James,

        Sorry for the late reply, the MODX forum didn't notify me of your message. When you check out the core class on line #895 in the current release, you can see how I create a plugin reference.

        $this->mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($this->_logger));


        Your example would simply be revamped like so:

        //Rate limit to 100 emails per-minute
        $modx->mail->mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin(
          100, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE
        ));
         
        //Rate limit to 10MB per-minute
        $modx->mail->mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin(
          1024 * 1024 * 10, Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE
        ));


        Haven't tried it, but that should work! Let me know!

        Also, Swift Mailer has only a couple of native plugins, which you can enable via my own class like so:

        $modx->mail->plugin(throttler', array(
        		'active' => false,
        		'rate' => 100,
        		'mode' => 'messages' // toggle 'bytes' for Bytes ;) Do yehr own calculation
        	)
        ));


        That should work! smiley [ed. note: ReSpawN last edited this post 10 years, 1 month ago.]
          @MarkGHErnst

          Developer at Adwise Internetmarketing, the Netherlands.
        • Many thanks ReSpawN. Haven't tried it as yet - but am sure it will work fine.
          • Hi

            Another quick query. How do I turn off the summary text that appears on the snippet page after the email(s) are sent? (summary of recipients etc.)

            Thanks

            • Summary for text? Can you post that please? smiley A screenshot would suffice as well.
                @MarkGHErnst

                Developer at Adwise Internetmarketing, the Netherlands.
              • For example, when I send a simple email to two recipients, I get the following at the top of the page:

                string(47) "Recipient Name One " string(46) "Recipient Name Two "

                Looks like it's summarizing the email and name of the two recipients.
                • Looks like you've got some stray var_dumps somewhere. I've checked the release I've got installed right here and it does not contain any var_dumps...

                  --edit

                  Ah, it looks like there is a stray var_dump in the code since development.

                  It's in modx/mail/swiftmailer/model/swiftmailer/classes/Swift/Transport/SimpleMailInvoker.php on line #49. You can remove that line. smiley Don't forget to reset the owner if you're using linux since it's installed under apache or root if your server allows it, which I doubt. smiley I'll make a new push to the Extra's ASAP.
                    @MarkGHErnst

                    Developer at Adwise Internetmarketing, the Netherlands.
                  • Hmm. Strange. I have the latest modSwiftMailer installed (0.3.1). This is the snippet code (or the relevant bit anyway):

                    $modx->getService('mail', 'mail.modSwiftMailer');
                    		  $modx->mail->address('to', $email, $fullname);
                    		  $modx->mail->address('sender', 'email@email.com');
                    		  $modx->mail->address('from', 'email@email.com', 'company name');
                    		  $modx->mail->replyto('email@email.com');
                    		  $modx->mail->bounce'email@email.com');
                    		  $modx->mail->subject('Your username');
                    		  $modx->mail->body('<html>stuff here</html>');
                    
                    		  $modx->mail->send();
                    		  $modx->mail->reset();

                    I get summary text appearing on both sites where I use modSwiftMailer. I haven't added anything else, or combined with any other snippets etc.
                    • See my previous reply. smiley
                        @MarkGHErnst

                        Developer at Adwise Internetmarketing, the Netherlands.