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

    MODx (1.0.2) is not sending user’s password updates or new user’s passwords via email. Anyone else experience this issue or know how to fix it?

    Thanks,
    Jess
    • Are you getting an error message?
      I’ve just confirmed that this is working for me on a 1.0.2 install.
      There are a few reasons why mail may not get delivered.

      First, PHP’s mail settings may not be configured properly, so when MODx uses PHP’s mail() function, it would give an error like this:

      Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in xxx\yyy\manager\processors\save_web_user.processor.php on line 419
      


      If PHP is configured to suppress error messages, you won’t see the error at all, which makes it hard to know.

      Second, if your web server is not the "trusted source" for mail from your domain (a DNS config issue) then a lot of mail recipients may either mark the mail as spam or block it outright. This one is less likely IMO.
        Mike Schell
        Lead Developer, MODX Cloud
        Email: [email protected]
        GitHub: https://github.com/netProphET/
        Twitter: @mkschell
        • 20508
        • 157 Posts
        Thanks for responding. I’m not getting an error message but the alert that I get doesn’t say anything (see attachment). I get no alerts for updating a password, it seems to be working fine but emails are just not getting delivered.
        • Here’s a way to see if php can even send mail, not involving modx.

          Create a php file in the root of your site called "test_mail.php".
          In it, put the following code:

          <?php
          /**
           * test php default mailer
           */
          ini_set('display_errors', true);
          
          $to = '[email protected]';
          $subj = 'test subject';
          $msg = 'test message';
          
          $result = mail($to, $subj, $msg);
          $yn = $result ? 'Yes' : 'No';
          
          echo "Mail sent? $yn";
          


          Edit the email address, then load up the page in your browser.

          It will tell you whether it worked or not. It might show you error messages.
          If it says that the mail was sent, yet you do not receive it, I’m not sure what to suggest then. It might be something to take up with your hosting provider or sysadmin.
            Mike Schell
            Lead Developer, MODX Cloud
            Email: [email protected]
            GitHub: https://github.com/netProphET/
            Twitter: @mkschell
            • 29055
            • 7 Posts
            Hi, I’ve got the same problem.
            Tried sending e-mails the way suggested by netProphET - it works, I get them. It means there are no server restrictions from my admin. But still, users can’t receive their password recovery e-mails etc, which are being send via MODX.
            Is there any solution?
              • 18913
              • 654 Posts
              Did anyone get a solution to this? I’m having the same problem with a new install of Evo 1.0.3 netProphet’s test.php sends mail fine and I get the email. Nothing has been added to the Evo install - it’s literally a fresh install with the WebLoginSidebar put in place in the MODxHost template.
              Matt
              • This will have to be added to Jira.
                Can anyone experiencing this problem please report the usual.. PHP version, MySQL version, MODx version, browser and any other details. If you see any messages logged in Reports > System Events in the Manager that correspond to the time of the problem, please include that.
                The more detail we can get into Jira, the better chance there is of solving the problem, especially when a bug doesn’t occur for everyone.
                I’ll file the ticket once some detail starts to come through.
                Thanks
                  Mike Schell
                  Lead Developer, MODX Cloud
                  Email: [email protected]
                  GitHub: https://github.com/netProphET/
                  Twitter: @mkschell
                  • 18913
                  • 654 Posts
                  For what it’s worth, I pulled some code from the ’net to change the above test script to this and saw that both email approaches worked, but I ded not get an email when selecting "Forgot Password" as noted above. Test script :
                  <?php
                  /**
                   * test php default mailer
                   */
                  ini_set('display_errors', true);
                  
                  $to = '[email protected]';
                  $subj = 'test subject';
                  $msg = 'test message';
                  
                  $result = mail($to, $subj, $msg);
                  $yn = $result ? 'Yes' : 'No';
                  
                  echo "Mail sent via 'mail'? $yn\n";
                  
                  $fd = popen("/usr/sbin/sendmail -t","w") or die("Couldn't Open Sendmail");
                  fputs($fd, "To: [email protected] \n");
                  fputs($fd, "From: \"You1\" <[email protected]> \n");
                  fputs($fd, "Subject: Test message from my web site \n");
                  fputs($fd, "X-Mailer: PHP5 \n\n");
                  fputs($fd, "Testing. \n");
                  pclose($fd);
                  
                  echo "Mail sent via sendmail okay\n";
                  
                  ?>
                  

                  If I have a php.ini file with
                  sendmail_path = /usr/sbin/sendmail -t -i
                  

                  I get an error dialog box saying "Error sending email [...]"

                  If I have a php.ini file with
                  sendmail_path = /usr/sbin/sendmail -t -i -nYourCompanyName
                  

                  I get a message saying to check my inbox. But nothing arrives. I suspect it’s failing and it’s not getting caught?

                  The thing I still cannot figure out is that I have this working on another site where the MODx install is in a subfolder and has it’s own php.ini file. I cannot figure out what the difference is in the setup. Time to call Bluehost, I guess.

                  Other details :
                  FireFox 3.6.3
                  MODx Evo 1.0.3
                  PHP Version 5.2.13
                  MySQL 5.1.46
                  host = Bluehost

                  Finally, the goal of this is to get a "friendly" "From" field as seen in the second approach in the test script above. If there’s another way I can do that instead of messing with a php.ini file, that would be one less thing there is to screw up.

                  TIA,
                  Matt
                    • 18913
                    • 654 Posts
                    Okay, at least in my case, I appear to have this problem solved.

                    The issue was traced to the email address in the Tools->Configuration->User panel that was not recognized as valid by the box that the MODx installation was running on.

                    So by going into cPanel (on bluehost), setting up an email account and then using this as the address for both the administrator and the site (via the User tab) I was able to get emails sent. Of course, selecting a pre-existing valid email would work too.

                    This was using the default php.ini file. In order to use the extra parameter for sendmail (as noted above), I needed to change the php settings in cpanel to use the php.ini file found in the public_html folder. This allows me to use an email in the User tab that has this form :
                    Test Co. <[email protected]>
                    A "forgotten password" email now comes through with the From field showing "Test Co." rather than box123[...].

                    Hope this helps someone. And I appreciate the thought that was put into the replies I’ve gotten.

                    MattC
                      • 42541
                      • 18 Posts
                      Hi all,

                      I spent some hours fighting with the same problem, php mail function working when i write my own snippet, but Login didn't send any activation either password reminder emails.

                      I changed modx settings to smtp: first to smtp serwer which is the same server as site. Didnt work...
                      Then I changed to gmail and... success ! Everything works !

                      Conclusion - choose server that allow to use php mail or change smtp to gmail account.