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

Answered SMTP trouble

    • 51020
    • 670 Posts
    Hi all.
    I have a site which is failing to send emails to the client when a form is submitted.
    The forms are using the extra Formz builder.
    The client gave me their own SMTP settings to use.
    For some reason though, when I choose 'Use SMTP:YES' - I get the error:
    [2017-02-07 12:46:21] (ERROR @ /index.php) An error occurred while trying to email the Admin: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
    


    if I change this to 'no' - the email gets delivered to me on cc, but not to the client.

    I'm on Modx 2.4.2
    The site is hosted with Godaddy (client's choice - not mine!)

    Any ideas of things to try?

    I tried with a gmail account and using Gmail SMTP - but same issue - I cannot turn on 'Use SMPT' which I assume I need to?

    This question has been answered by BobRay. See the first response.

      • 22840
      • 1,572 Posts
      Bob Rays Quick email snippet can help diagnose and solve email problems if you havent already tried it

      http://bobsguides.com/quickemail-snippet-tutorial.html
        • 51020
        • 670 Posts
        Yes tried that thanks - the errors I get are:

        Send Failed
        Mailer error info: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
        Server Debug Information:
        
        2017-02-07 14:19:37	SMTP ERROR: Failed to connect to server: Connection refused (111)
        2017-02-07 14:19:37	SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
        
        
        
        


        But I don't ave a clue how to fix it!
          • 51020
          • 670 Posts
          But - if i change use SMTP: to NO - it sends without a problem to me. But it doesn't get through to the client. How does it work when SMTP is set to no?
            • 3749
            • 24,544 Posts
            Your host may be blacklisted by the host of your SMTP account, or you may not have the required ant-spam elements set up on your host.

            It's also possible that your SMTP setting (especially port and tls/ssl). Your host probably has instructions on outgoing SMTP in their knowledge base. If not, you could file a ticket.

            When you set use SMTP to NO, MODX uses the PHP mail() function, which is disabled on many hosts.
              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
              • 51020
              • 670 Posts
              Quote from: BobRay at Feb 09, 2017, 12:25 AM
              Your host may be blacklisted by the host of your SMTP account, or you may not have the required ant-spam elements set up on your host.

              It's also possible that your SMTP setting (especially port and tls/ssl). Your host probably has instructions on outgoing SMTP in their knowledge base. If not, you could file a ticket.

              When you set use SMTP to NO, MODX uses the PHP mail() function, which is disabled on many hosts.

              Ah Thank you Bob - Appreciate your input - I will speak to the host again The weren't much help when I first tried - but I will persist - I just wanted to rule out any error by me first, but I think that my set up is correct.

              Thanks
              Andy
                • 51020
                • 670 Posts


                Quote from: BobRay at Feb 09, 2017, 12:25 AM
                Your host may be blacklisted by the host of your SMTP account, or you may not have the required ant-spam elements set up on your host.

                It's also possible that your SMTP setting (especially port and tls/ssl). Your host probably has instructions on outgoing SMTP in their knowledge base. If not, you could file a ticket.

                When you set use SMTP to NO, MODX uses the PHP mail() function, which is disabled on many hosts.

                Ok - as a workaround, I have set up a dedicated gmail account to run the site in terms of email delivery.
                Initially it wouldn't send with SMTP - due to Gmail blocking access from a "less secure app'.
                Within gmail, there is an option to 'allow less secure apps' - which I tried - and this allowed the email to be sent.

                I tried the Gmail SMTP settings of:

                SMTP Authentication: yes
                SMTP hosts: smtp.gmail.com
                SMTP port: 587 (also tried 465)
                SMTP Connection Prefix: tls (also tried ssl)
                USE SMTP: YES

                Obviously this isn't ideal - as it's more open to attacks - does anyone know a way to prove this is not a 'less secure app'?

                Or - is it safe to turn off this additional layer of security within Gmail?

                Thanks
                Andy
                • discuss.answer
                  • 3749
                  • 24,544 Posts
                  Here's some more info on Gmail's rejection: http://www.ghacks.net/2014/07/21/gmail-starts-block-less-secure-apps-enable-access/.

                  My take on it is that allowing 'less secure apps' is fine, though there's no guarantee that it will continue to be available as an option.

                  After wrestling with Gmail for a while, I finally switched to Mandrill. When that was no longer free, I went to Mailgun. There's example code for Mailgun in the files of the Notify extra (the MailgunX class). I get much better deliverability with MailGun, and I no longer have to worry about what Gmail will do next. The developers at Mailgun do the worrying for me. You can send up to 10,000 emails per month for free. You do have to jump through some hoops to set up the Mailgun account, but you only have to do it once and it's fairly well-documented.

                  FYI, if you want make sure the emails don't end up in the spam bin, be sure to send the proper DKIM and/or SPF records.




                    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
                    • 51020
                    • 670 Posts
                    Quote from: BobRay at Feb 09, 2017, 10:47 PM
                    Here's some more info on Gmail's rejection: http://www.ghacks.net/2014/07/21/gmail-starts-block-less-secure-apps-enable-access/.

                    My take on it is that allowing 'less secure apps' is fine, though there's no guarantee that it will continue to be available as an option.

                    After wrestling with Gmail for a while, I finally switched to Mandrill. When that was no longer free, I went to Mailgun. There's example code for Mailgun in the files of the Notify extra (the MailgunX class). I get much better deliverability with MailGun, and I no longer have to worry about what Gmail will do next. The developers at Mailgun do the worrying for me. You can send up to 10,000 emails per month for free. You do have to jump through some hoops to set up the Mailgun account, but you only have to do it once and it's fairly well-documented.

                    FYI, if you want make sure the emails don't end up in the spam bin, be sure to send the proper DKIM and/or SPF records.


                    Thanks for this Bob - I will take a look at Mailgun - sounds like a good option.
                    Off topic: Loving your book by the way - had it since I was first introduced to Modx two years ago - and it's always been a really useful resource (as is this forum!).
                      • 3749
                      • 24,544 Posts
                      Thanks for buying my book. smiley

                      It's not as current as the eBook, but it has a way better index. wink
                        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