We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23299
    • 1,161 Posts
    I recently updated a site to MODx. All is good but the site owner is not receiving emails from the contact form?

    The form seems to work from the front end. The thanks message appears once you hit send etc.

    The tech support guy from the host emailed me asking if:
    Hi, did you mail script include mail authorization due to all our server need smtp authorization to send out mail. Could you please have a check? If you problem persists, could you please post your script which handle the mail function?

    I sent him a copy of my snippet call and the actual code from the eForm 1.4.4.6 snippet.

    I am drowning in uncharted waters here: is there anything else I can try? Does this mean that I need to alter the snippet code to authorize SMTP?

    Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Yes. In the assets/snippets/eform/eform.inc.php file you need to change the $mail->isMail to something like this:
      $mail->IsSMTP();
      $mail->Host = 'smtp.domain.com';
      $mail->SMTPAuth = true;
      $mail->Username = 'username';
      $mail->Password = 'password';
      

      This needs to be done in five places in the file: lines #351, #443, #461, #479, 496.

      You can also modify the manager/includes/controls/class.phpmailer.php file, around line #174, to set the $SMTPAuth to true, and set the username and password in the lines below that. Then you would only need to change the one line in the five places in the eform.inc.php file from isMail to isSMTP. This would also help in any other mailing applications you might find the site using.
        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
        • 23299
        • 1,161 Posts
        I tried the second option...

        Will report back when I know the results...

        Thanks Susan!

        PS: is this common?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Very. And getting more so as more hosting companies are locking down their email servers to try to slow down the flood of spam.
            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
            • 23299
            • 1,161 Posts
            Interesting...

            Would it not be a good idea to include a new version of the eForm php file to the MODx archive to accommodate this trend?
              • 3749
              • 24,544 Posts
              Quote from: Photowebmax at Nov 30, 2009, 09:33 PM

              Interesting...

              Would it not be a good idea to include a new version of the eForm php file to the MODx archive to accommodate this trend?

              SPForm might not meet your contact form needs, but it is very easy to configure for SMTP.
                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
                • 23299
                • 1,161 Posts
                I am waiting to hear from the site owner if this working.

                What a hassle! Usually I can stick my own address in the form to make sure the from is working, but I think this host needs the real address. This slows down the whole show. In the meantime I know the site owner is not happy with not getting any emails delivered from the site for a couple of days. I might just have to stick an old fashioned email link on the contact page...
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  You should be able to use any address as the &to address. I do it all the time when developing sites. My own VPS requires authenticated SMTP, and even uses a totally different mail server. I suppose some really paranoid mail servers might require a local from address, but requiring a specific to address makes no sense at all.
                    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
                    • 23299
                    • 1,161 Posts
                    I tried making the change to the eForm PHP file and I get this message when send the form:

                    CCSender: Mailer was unable to send mailSMTP Error: The following recipients failed: [email protected]

                    This is the change I have made in those places as indicated by Susan:
                    $mail = new PHPMailer();
                    					$mail->IsSMTP();
                    					$mail->Host = 'mail.sitename.com';
                    					$mail->SMTPAuth = true;
                    					$mail->Username = 'username';
                    					$mail->Password = 'custompassword';
                    					$mail->IsHTML($isHtml);
                    					$mail->From		= $modx->config['emailsender'];
                    					$mail->FromName	= $modx->config['site_name'];
                    					$mail->Subject	= $_lang['ef_mail_abuse_subject'];
                    					$mail->Body		= $body;
                    					AddAddressToMailer($mail,"to",$modx->config['emailsender']);
                    					$mail->send(); //ignore mail errors in this case


                    I think I am close as a previous attempt would trigger a server error...


                    OK, it looks like some of the messages are getting through but I am still getting the error massage as above. Do I need to adjust the FROM field in any way?
                      • 23299
                      • 1,161 Posts
                      I did some digging in the host site and found this:
                      Here’s a sample for using SMTP. Our server setting REQUIRES all customers to use SMTP authorization in order to send out email. You can acquire a copy of phpmailer class from http://sourceforge.net/project/showfiles.php?group_id=26031. You should upload the file "class.phpmailer.php" to same folder for your script.

                      IMPORTANT: From email address and your authorization email address MUST be same.


                      <?php
                      require("class.phpmailer.php");
                      $mail = new PHPMailer();
                      $mail->CharSet ="utf-8"; // You can adjust the Charset according to your language
                      $mail->IsSMTP();
                      $mail->Host = "mail.Yourdomain.com";
                      $mail->From="[email protected]"; //REMEMBER, this MUST be same as your authorization email address above.
                      $mail->FromName="My site’s mailer";
                      $mail->SMTPAuth = true;
                      $mail->Username = "[email protected]";
                      $mail->Password = "yourpassword";

                      $mail->AddAddress("sendTOemail");
                      $mail->Subject = "Test 1";
                      $mail->Body = "Test 1 of PHPMailer.";

                      if(!$mail->Send())
                      {
                      echo "Error sending: " . $mail->ErrorInfo;;
                      }
                      else
                      {
                      echo "Letter is sent";
                      }?>


                      So, it looks like I need to add the From email address here?

                      This is what I have in the eForm PHP:
                      $mail = new PHPMailer();
                      					$mail->IsSMTP();
                      					$mail->Host = 'mail.siteaddress.com';
                      					$mail->SMTPAuth = true;
                      					$mail->Username = 'username';
                      					$mail->Password = 'actualpassword';
                      					$mail->IsHTML($isHtml);
                      					$mail->From		= $modx->config['emailsender'];
                      					$mail->FromName	= $modx->config['site_name'];
                      					$mail->Subject	= $_lang['ef_mail_abuse_subject'];
                      					$mail->Body		= $body;
                      					AddAddressToMailer($mail,"to",$modx->config['emailsender']);
                      					$mail->send(); //ignore mail errors in this case