On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Thanks BobRay, I had a look at Mailgun and will give it a try. Silly question, do you have some hints or examples how to implement the Mailgun service in MODX?
    • Quote from: flipflop1974 at Nov 10, 2018, 09:57 AM
      Thanks BobRay, I had a look at Mailgun and will give it a try. Silly question, do you have some hints or examples how to implement the Mailgun service in MODX?

      This looks useful, its new, is it only for cloud installations though, I am not sure

      https://support.modx.com/hc/en-us/articles/216947987-Configure-MODX-to-Use-an-Email-Service-Provider
      • Notify will use Mailgun out of the box. You could look at the Notify code if you want to implement it in other places. I've never done it.

        Look at the MailgunX class in the Notify files under core/components/notify.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
        • Quote from: BobRay at Nov 10, 2018, 05:53 PM
          Notify will use Mailgun out of the box. You could look at the Notify code if you want to implement it in other places. I've never done it. Look at the MailgunX class in the Notify files under core/components/notify.

          Hi Bruno,

          I've set up Mailgun right now. I configured it in the Notify Props:
          mailService => MailgunX
          mailgun.domain => my freshly created and by Mailgun verified subdomain 
          mailgun_api_key => the key provided by Mailgun


          When trying to send an email now, I get "Results: E-mail to subscribers sent successfully to 1 recipients using MailgunX"
          But no Email was sent at all.

          So I turned on the dubug mode
          mailgun.debug => Yes


          And that's the content of the log (I just replaced some sensitive data with asterisks) after trying to send 1 Email:

          [2018-11-14 15:57:30] (ERROR @ /var/www/vhosts/*****/httpdocs/core/components/notify/model/notify/mailgunx.class.php : 96) 
           **********  MailgunX class **********
          
          [2018-11-14 15:57:30] (ERROR @ /var/www/vhosts/*****/httpdocs/core/components/notify/model/notify/mailgunx.class.php : 231) 
          
          Prepared Tpl
          TEST CONTENT
          [2018-11-14 15:57:30] (ERROR @ /var/www/vhosts/*****/httpdocs/core/components/notify/model/notify/mailgunx.class.php : 262) 
          
          Final Fields
          Array
          (
              [from] => ***** ***** <**@*****.**>
              [subject] => *******
              [text] => TEST CONTENT
              [html] => TEST CONTENT
              [h:Reply-To] => 
              [to] => ******.*****@*****.**
              [recipient-variables] => []
          )
          
          [2018-11-14 15:57:31] (ERROR @ /var/www/vhosts/*****/httpdocs/core/components/notify/model/notify/mailgunx.class.php : 262) 
          
          Final Fields
          Array
          (
              [from] => ***** ***** <**@*****.**>
              [subject] => *******
              [text] => TEST CONTENT
              [html] => TEST CONTENT
              [h:Reply-To] => 
              [to] => ******.*****@*****.**
              [recipient-variables] => []
          )




          I can't manage to get the exact cause of the errors. Do you?
          The line number references in the ERROR log (eg 231 or 262) just brought me to the line where Notify writes the error to the log but not (as I assumed) to the line of code where the error is thrown.

          So I got stuck right now... Any ideas are highly welcome ;-)

          • There is some information here about setting up Mailgun with Notify: https://bobsguides.com/notify-tutorial.html (toward the end of the article).

            Mailgun now requires that you give them a credit card, so if you haven't, that could be the issue. I receive "bills" from them, but the charge is always $0.

              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
            • discuss.answer
              I've just discovered that Mailgun requires PHP 5.4 or above, which could be your issue.

              I may also have discovered why modMailX is sending duplicates. If you want to go back to it, you can edit the core/components/notify/processors/mgr/nfsendemail.class.php file and try changing line 503 from:

              $maxAttempts = 3;

              To
               $maxAttempts = 1;


              Though I should mention that in addition to the deliverability issues, modMailX is very slow because it doesn't allow true templating variables so it requires that each email be sent individually.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
              •  $maxAttempts = 1;

                Did the trick! Maaaaany thanks Bob!

                Beside that, my PHP Version is 7.1.22 and all my credit card details are submitted to Mailgun.
                Nevertheless, currently I am very happy with this solution, so I will probably continue the mailgun setup later.

                By the way, thank you for your help here in the forum all the time. I've had some problems with MODX before, and you answer almost every question. That said: Thanks again for your time, patience and effort!
                Just wanted to say that.
                • Thanks for the kind words. I'm glad I could help.

                  Another possible issue with Mailgun is that the SPF and DKIM records are not set up or incorrect. It took me a while to get them right.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                  • Is mailgun also used for stuff like user registration and confirmation emails?

                    Or is it more for mass emails to all users in a group?
                    • The MailgunX class that comes with Notify could be used for that, but the documentation might be a little thin and the class may change soon.

                      There is also a mailgun-php package available via Composer that would probably be a better choice.

                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting