We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24598
    • 17 Posts
    I am running MODX on a windows server. My mail provider requires me to perform SMTP authentication.

    I have the following code in a test snippet:

    <?php
    //$to = "XXXXX@WEBSITE_HOSTED_WITH_ARVIXE.com";
    $to = "[email protected]";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "[email protected]";
    $headers = "From: $from";
    mail($to,$subject,$message,$headers);
    echo "Mail Sent.";
    ?>

    When I run the above with $to = "XXXXX@WEBSITE_HOSTED_WITH_ARVIXE.com"; it works perfectly.

    When I run with $to = "[email protected]";

    I get:

    « MODX Parse Error »
    MODX encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »
    PHP error debug
    Error : mail() [function.mail]: SMTP server response: 530 SMTP authentication is required.
    ErrorType[num] : WARNING[2]
    File : C:\HostingSpaces\ctwhite\ctwhitetailassociation.com\wwwroot\manager\includes\document.parser.class.inc.php(828) : eval()'d code
    Line : 9
    Basic info
    REQUEST_URI : /index.php?id=62
    Resource : [62]Testing
    Current Snippet : testmail
    Referer :
    User Agent : Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36
    IP : 71.235.120.9
    Benchmarks
    MySQL : 0.0000 s (8 Requests)
    PHP : 0.1248 s
    Total : 0.1248 s
    Memory : 2.402961730957 mb

    Backtrace

    1 DocumentParser->executeParser()
    index.php on line 136
    2 DocumentParser->prepareResponse()
    manager/includes/document.parser.class.inc.php on line 1294
    3 DocumentParser->outputContent()
    manager/includes/document.parser.class.inc.php on line 1385
    4 DocumentParser->parseDocumentSource()
    manager/includes/document.parser.class.inc.php on line 491
    5 DocumentParser->evalSnippets()
    manager/includes/document.parser.class.inc.php on line 1186
    6 DocumentParser->_get_snip_result()
    manager/includes/document.parser.class.inc.php on line 874
    7 DocumentParser->evalSnippet()
    manager/includes/document.parser.class.inc.php on line 956
    8 eval()
    manager/includes/document.parser.class.inc.php on line 828
    9 mail()
    manager/includes/document.parser.class.inc.php(828) : eval()'d code on line 9


    I know I have to modify the underlying SMTP classes and add the host/user/password but not sure where.

    I get the same error when I try to use the web snippet weblogin on this call:

    // Send new password to the user
    function webLoginSendNewPassword($email,$uid,$pwd,$ufn){

    Any help would be appreciated.

    Thanks in advance.
    • Your script is using the PHP mail() function, which your hosting company is restricting to sending local mail only. For mail to any external recipients, you have to use SMTP, not the PHP mail() function.

      You need to set the system setting Sendmail Method, as well as the other SMTP settings in the User tab. EForm will use these settings, I'm not sure if the login snippets have been re-written to do so.
        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
      • Basically, you need to include the manager/includes/exenders/modxmailer.class.inc.php file, create a new "mail" object from it, then pass it the parameters for sending the mail.

        This is from eForm:
        $modx->loadExtension('MODxMailer'); // or include it 
        ...
        $modx->mail->IsHTML($isHtml);
        $modx->mail->From	    = $from;
        $modx->mail->FromName   = $fromname;
        $modx->mail->Subject    = $subject;
        $modx->mail->Body	    = $report;
        // functions to simplify handling to addresses and file attachments					AddAddressToMailer($modx->mail,"replyto",$replyto);
        AddAddressToMailer($modx->mail,"to",$to);
        AddAddressToMailer($modx->mail,"cc",$cc);
        AddAddressToMailer($modx->mail,"bcc",$bcc);
        AttachFilesToMailer($modx->mail,$attachments);	
        
        if(!$modx->mail->send()) return 'Main mail: ' . $_lang['ef_mail_error'] . $modx->mail->ErrorInfo;
        
          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
          • 24598
          • 17 Posts
          I could not find MODXMailer... not sure its included in Modx Evolution...

          There are two classes found under: manager/includes/controls

          class.phpmailer.php
          class.smtp.php

          Couldn't I simply use those ?



          • Ah. I'm testing version 1.0.11.

            You should be able to just include the phpmailer class then.
              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
              • 24598
              • 17 Posts
              Quote from: sottwell at Aug 16, 2013, 07:23 PM
              Ah. I'm testing version 1.0.11.

              You should be able to just include the phpmailer class then.

              I am getting this error now:

              SMTP -> ERROR: Password not accepted from server: 535 Authentication failed. Restarting authentication process. SMTP -> ERROR: RCPT not accepted from server: 530 SMTP authentication is required. Mailer Error: SMTP Error: The following recipients failed: [email protected]
              • Well, that's pretty clear, the SMTP mail server you're using doesn't like your password.
                  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