We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4310
    • 2,310 Posts
    This is beta for testing therefore backup everything you're going to change!
    This extends eForm, without affecting the existing mail() method of sending, you just get the additional option of using SMTP.
    Normally I'd post it in the development section, but it's more likely to find SMTP testers here.
    I've attached a zip file containing:
    instructions.rtf ( read before doing anything else! )
    eform.snippet.php ( new MODx Snippet )
    eform.inc.php ( main code for eForm )
    6 new SMTP snippet parameters available & have the following default values :
    <?php
    'smtp' => isset($smtp)? $smtp:false, // false to use IsMail(); function, true to use IsSMTP(); function 
    'smtp_host' => isset($smtp_host)? $smtp_host:'', // e.g. smtp.your-domian.co.uk
    'smtp_port' => isset($smtp_port)? $smtp_port:25, // e.g. 587 or another port, check with your hosting/email provider
    'smtp_auth' => isset($smtp_auth)? $smtp_auth:'true', // true or false, check with your hosting/email provider but usually true
    'smtp_user' => isset($smtp_user)? $smtp_user:$modx->config['emailsender'], // any valid SMTP user e.g. [email protected]
    'smtp_pass' => isset($smtp_pass)? $smtp_pass:'', // whatever the password is for the user
    

    I've only done limited testing, so be warned  ;)
    Post any bugs in the forum thread, I'm sure there are plenty!
    Additionally I added a new parameter 'sender'.
    I noticed some servers have the PHP 'sendmail_from' value default to '[email protected]' the new sender parameter enables you to override it so your email header will have an accurate 'Return-Path' value.
     
    <?php
    'sender' => isset($sender)? $sender:$modx->config['emailsender']  //  e.g. [email protected] 

    #1 EDIT zip file now contains a merged version of the security Mods by PMS, see link/suggestion by sharkbait in post#2 & the new SMTP functionality in eform.inc.php
    #2 EDIT zip file now contains an updated eform.snippet.php to use sotwell's config suggestion in post#4
    #3 EDIT zip file now contains a fixed version of eform.inc.php, rectifying issues in post#6 also there is an example.config.php file
    #4 EDIT the snippet code was a duplicate of the main inc. file, my apologies, now corrected [ed. note: bunk58 last edited this post 11 years, 3 months ago.]
      • 26931
      • 2,314 Posts
      Hey David,

      thanks for sharing! maybe we could merge this update with the security fixes from this thread: http://modxcms.com/forums/index.php/topic,38336.msg239873.html#msg239873 or are they already?

      thanks, j

        • 4310
        • 2,310 Posts
        I hadn’t noticed the fixes there rolleyes
        I’ll have a look at them and see if I can integrate them into my SMTP version.
        • I’ve added an external config file feature to mine; it just adds a few lines of code to the beginning of the snippet to include a file if the &config parameter is set and the indicated file exists in assets/snippets/eform/configs. Great for conditional configuration settings, not to mention simplifying the snippet call.
          $config = isset($config) ? "assets/snippets/eform/configs/$config.config.php" : "assets/snippets/eform/configs/default.config.php";
                  if (file_exists($config)) {
          	    include_once("$config");
                  }
          
            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
            • 4310
            • 2,310 Posts
            Thanks for both of the suggestions, now done.
            Will need to test it out after the mods.
              • 4310
              • 2,310 Posts
              Still needs some work.
              I only tested on a domain without the mail() function.
              Seems when you have mail() available and select smtp you get the email sent by both methods.
              Will need to look at my if/&& statements again sad
                • 4310
                • 2,310 Posts
                Okay, the zip file in the first post now has the fixes to stop sending the email by both methods, at the same time laugh
                  • 4310
                  • 2,310 Posts
                  Completed some minor code refactoring, so the zip file has been updated.
                  So far tested with :
                  &ccsender
                  &cc
                  &bcc
                  &sendirect
                  &noemail

                    • 4310
                    • 2,310 Posts
                    The zip file has been updated due to me copying and pasting incorrectly rolleyes
                    Now also tested with :
                    &debug
                    &config
                    &mailselector
                      • 23299
                      • 1,161 Posts
                      Wow! This looks really useful...