We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16680
    • 73 Posts
    Hey

    Just installed EForm and think that its a fantastic piece of snippet..

    However I got one problem.
    Example:

    [!eForm? &subject=`new user` &to=`[email protected]` &automessage=`ContactFormReply` &autosender=`[email protected]` "autoSenderName=`Ziestha` !]

    When a user fills out and sends this form he will get a confirmation email, plus I will get a mail notifying me of the registration.
    How can I make different subjects so that my mail would display e.g. "New user registration" and the new users would be e.g. "Thank you for joining"?


    Thanks

    larsb
      Signature on it's way
      • 23653
      • 10 Posts
      Having the same problem. Just wanted to follow up with a response I guess. Having problems trying to assign multiple subjects with eforms. Ive seen other scripts that work, but would rather stick with Eform, since its integrated on the site. Please help.

        • 30223
        • 1,010 Posts
        There’s two ways of approaching this that I can think of, both are kinda ugly..

        1. You can hack eForm and make yourself a new parameter for the extra subject.

        2. You copy the code from eform for sending the second mail and place that in an event function, adapting it to have a custom subject. Something like this should do it. If not, experiment with it (I didn’t try out this code).
        //<?php
        // place function in a new snippet and call this snippet (uncached) 
        // before eForm in your document.
        if(!function_exists('extraMail')){
            function extraMail(){
              global $modx;
               //get bodytext template from a chunk
              $bodytext = efLoadTemplate('yourChunk');
              $bodytext = formMerge($bodytext,$fields);
              //prepare mail
              $mail = new PHPMailer();
              $mail->IsMail();
              $mail->CharSet = $modx->config['modx_charset'];
              $mail->IsHTML(true); //change to false for plain text
              $mail->From      = '[email protected]';
              $mail->FromName   = 'Ziestha';
              $mail->Subject   = 'My custom Subject....';
              $mail->Body      = $bodytext;
              AddAddressToMailer($mail,"to",$fields['email']);
              if(!$mail->send()) 
                 return 'AutoText: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo;
           }
        }
        
        

        To make it work in the eForm call you set &eFormOnMailSent=`extraMail` and remove the &automessage, &autosender and the &autoSenderName parameters. The latter 3 are now dealt with in the function instead ( and you would want them to receive 2 email would you). Please do realize that you do not have direct access to eForm’s parameters within the event function, so you may have to hard code the data as I’ve done here.

        The second option must seem the best choice now that I’ve done most of the work for you, so be nice and throw a few coins in the donation box to keep the team going... smiley