We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I’m a little confused as to why in eForm there is no way to configure what PHPMailer calls the Sender, which is responsible for setting the very important Return-Path header on the message. In most cases, this should very definitely be an option, because depending on what kind of form you are building, you need to set this to where you expect bounces to go. By default, PHPMailer sends this to the From address in SMTP mode and to nothing in sendmail mode (very very bad). In SMTP if the from is the user filling out a Contact form to send to you as a recipient, and for some reason it can’t be delivered, it will try to bounce the mail to the user filling out the form. In sendmail mode, without the -f switch, you have no return-path. Both of these cases of course will generally fail and the only one who will ever know about your mail is the postmaster on your mail server.

    Am I missing something obvious here?
      • 5337
      • 6 Posts
      I spent ages looking at this as my client needed bouncebacks as well - this seems to do the trick.

      At line 70-4 of /manager/includes/controls/class.phpmailer.inc add the address to use
      * Sets the Sender email (Return-Path) of the message.  If not empty,
      * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
      * @var string
      */
      var $Sender            = "[email protected]";
      • Modifying phpmailer is not an option; this is an external, 3rd party class that is part of the core of MODx being used by eForm and is not meant to be edited. The option needs to be part of eForm itself, or everytime you upgrade MODx, you will lose the modifications.
          • 22673
          • 72 Posts
          I am also having an issue by not being able to set the Return-Path header. I have a client’s MODx site hosted in one place, and then the email accounts for the client in another. The eform is set to send to one of the email accounts. The email accounts are hosted by a domain/hosting company that have a strict email policy and they check to see if the Return-Path email address is a legitimate, working email address.

          This results in the emails from the eform being blocked and not reaching the client’s email account.

          Unfortunately for some reason, the Return-Path is not being set. We need it to be the form user’s email address.

          If we put a PHP echo in the PHPMailer file (class.phpmailer.php) and we see the Return-Path is being set correctly, but for some reason it is not being transferred into the email header. Instead the Return-Path seem to default to: [HOSTING-ACCOUNT-USERNAME]@domain.co.uk

          We have also tried adding the following lines of code into the eform.inc.php file:

          if($sendirect) $to = $fields['email'];
          $mail = new PHPMailer();
          
          // This bit
          ini_set("sendmail_from",$from);
          ini_set("sendmail_path","/usr/sbin/sendmail -t -i -f ".$from);
          //
          
          $mail->IsMail();
          $mail->CharSet = $modx->config['modx_charset'];
          $mail->IsHTML($isHtml);
          $mail->From	= $from;
          $mail->FromName	= $fromname;
          $mail->Subject	= $subject;
          $mail->Body	= $report;
          
          // And this bit
          $mail->Sender   = $from;
          //
          
          AddAddressToMailer($mail,"replyto",$replyto);
          AddAddressToMailer($mail,"to",$to);
          AddAddressToMailer($mail,"cc",$cc);
          AddAddressToMailer($mail,"bcc",$bcc);
          AttachFilesToMailer($mail,$attachments);
          if(!$mail->send()) return 'Main mail: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo;


          Can anyone help because this is a nightmare.
          We have: MODx 1.0.3, eForm 1.4.4.6, PHPMailer 1.73

          Alex.

          PS: we dont want to set the: var $Sender as that will be overwritten in future updates.
            • 31178
            • 128 Posts
            An old topic, but still seems there is no option to set the Return-Path header value?

            I’ve ended up adding a line in five places. The abuse logic and 4 ’sends’ after lines 353, 446, 464, 482 and 499 of eform.inc.php (v 1.4.4.6)

            $mail->Sender   = $modx->config['emailsender'];


            Adding it as the modx settings email address seems to make sense to me. I guess a parameter could be added to the eForm snippet to override it.
              • 4310
              • 2,310 Posts
              @uxello
              See my signature for a modified version, including a parameter for setting the sender.
                • 31178
                • 128 Posts
                thanks David I’ll give it a go. I think I had seen that in passing but thought it was only an SMTP update. Be nice if this could make it into an official release at some point.
                  • 22673
                  • 72 Posts
                  Quote from: bunk58 at Apr 16, 2011, 05:59 PM

                  @uxello
                  See my signature for a modified version, including a parameter for setting the sender.

                  @bunk58

                  Great update. Managed to get SMTP working however when I want to set the &sender parameter myself, it works with a hard coded email address only:


                  But not with the email address submitted in the form. Tried various syntax but the email doesn’t get through. See below where "email" is the name of the email address input in the form:
                  &sender=`email`
                  &sender=`((email))`
                  &sender=`[+email+]`
                  &sender=`[*email*]`
                    • 4310
                    • 2,310 Posts
                    @paramaniac
                    The &sender parameter was added to enable the originating server/source to be shown correctly.
                    If you want to indicate who the actual individual was that filled in the form, then use the &from parameter, using a placeholder, system sender or form field.
                      • 38733
                      • 22 Posts
                      Editing PHPMailer is easy but a hack. Does anyone still have the modified eForm with &sender param? It should also be a permanent eForm feature.