We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1778
    • 659 Posts
    • I am trying to do what Bert was searching for. I have a hook that creates an XML file based on user input values on the form. I want to send the XML file as an attachment "programmatically" in the hook. So my form does not have an input field for this, so this is not a basic add a file type input field on a form.

      so a reduced version of this hook prototype looks like this:

      <?php
      //get form values
      $modx->log(xPDO::LOG_LEVEL_ERROR,'Testing my custom hook.');
      $emailVal = $hook->getValue('email');
      /*$nameVal = $hook->getValue('name');
      $subjectVal = $hook->getValue('subject');
      $textVal = $hook->getValue('text');*/
      
      $doc = new DOMDocument('1.0');
      // we want a nice output
      $doc->formatOutput = true;
      
      $root = $doc->createElement('person');
      $root = $doc->appendChild($root); //creates the person 
      
      $email = $doc->createElement('email'); //creates element
      $email = $root->appendChild($email); //assigns element
      
      $emailTxt = $doc->createTextNode($emailVal); // assigns email value to the text node
      $emailTxt = $email->appendChild($emailTxt); // assigns the text node to the element email
      
      $content = $doc->saveXML();
      
      return true;


      In a resource this snippet works fine and shows the xml in the browser. What I am looking for here is the logic needed to take this xml file saved in the temp folder on the server and attach it to the email being sent from FormIt.

      Can anyone help out?
        Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
      • I ended up not using the email hook from FormIt, but wrote my own using modMail:
        http://rtfm.modx.com/revolution/2.x/developing-in-modx/advanced-development/modx-services/modmail
          Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.