We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6038
    • 228 Posts
    I’ve been given access to a fresh install of Ubuntu to redesign a site, and I’m *blush* a first-time MODx user, and having a little trouble enabling the MODx to use the SMTP settings.
    I have installed MODx 9.6.1 fresh, and set up a mysql database ok - everything working fine there. I can log in to the manager fine but i have noticed that at the manager login screen if i click ’forgot password’ and fill in the email address to remind me of my password, it returns an error - ’Error sending email’.

    I have to use SMTP (without authentication), and i have updated the /manager/includes/controls/class.phpmailer.php file with some details like so:
    var $Mailer = "smtp";
    var $Host = "10.xxx.xx.xx";
    var $SMTPAuth = false;

    I have written a simple php mailer example file which includes the class using the same file used in MODx, and tests it out using the same settings. It sends an email fine, sent and received. But the same class does not work from within the manager log-in page?

    Is there a setting elsewhere in MODx i need to change? Or is some module used for sending the email from this page overriding the default SMTP setting i have entered?

    I also tried modifying my php.ini file, so the SMTP server is recorded there also,
    SMTP = 10.xxx.xx.xx
    ...but even following an apache restart this didnt improve anything. So... all this leads me to think that something within MODx is causing the error by changing something, or not including the settings?

    Does anyone have any ideas on how i can troubleshoot this further?
    Or does anyone know how to get further info from MODx on what the error might be?

    MODx version: 9.6.1
    Server environment: Apache/2.2.4 (Ubuntu) running PHP/5.2.3 (running as mod_php i think)
    Mysql version: 5.0.5
    Testing in: Firefox 2 on Max OS X 10.3.9 (with webdeveloper and firebug installed)


      • 6038
      • 228 Posts
      Can anyone tell me which files handle the sending of email messages from within MODx? Files other than the phpmailer class i mean. Hopefully someone knows and can save me from having to figure out how modx actually works!

      I want to check any other settings that are controlled by MODx for when it sends you a reminder for your password - perhaps locating this will help me solve my problem with why emails are not sending.

      thanks
        • 6038
        • 228 Posts
        I finally solved this problem.

        I tracked down where the ’mail’ commands were being issued from:
        /manager/processors/save_user.processor.php
        /manager/processors/save_web_user.processor.php
        /assets/snippets/weblogin/weblogin.common.inc.php
        /assets/snippets/weblogin/weblogin.processor.inc.php


        ... but this wasnt the problem. I found out from lengthy searching that i had two options:

        1. modify the above files to use the phpmailer class instead of native php mail function
        2. enable php native mail function to send smtp relayed emails, by installing mail program such as sendmail, postfix or exim

        Not wanting to mess with the core of MODx led my to attempting to install sendmail - strangely it was not in my php version. Not being much of a server admin i wasn’t too keen on it - but the server admins didn’t really know anything about it so told me to go ahead! As it turns out it was too easy. At the command line i entered:

        [tt]sudo apt-get install sendmail[/tt]

        And then everything worked! Just like that!

        Just thought i would post the update in case it is of use to anyone else.

          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Actually sendmail has nothing to do with php. It’s a mail server, just as apache is a web server. Installing it on your server can open you to all kinds of security issues, so it’s not a trivial matter. I strongly suggest that you do some research into how to secure it, or how to replace it with more secure mail servers such as qmail.

          http://www.deer-run.com/~hal/sysadmin/sendmail.html
            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
            • 6038
            • 228 Posts
            Quote from: sottwell at Apr 28, 2008, 11:55 PM

            I strongly suggest that you do some research into how to secure it, or how to replace it with more secure mail servers such as qmail.

            Many thanks for the heads up - I would not have known about this.
            I am taking your advice and reading it now.


            PS: In my earlier solution, i neglected to mention that I also entered the name of the smtp relay host in my php.ini file, just in case, although this may or may not be necessary.