We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37105
    • 194 Posts
    Quote from: Steeve at Feb 24, 2017, 02:52 PM
    Hi,

    If you want just to send file with the email, normally you need to add in you form call
    enctype="multipart/form-data"


    Then add a file type field
    <input name="myFile" id="myFile" value="" type="file">


    And (last) in your email TPL (email-briefing-tpl) add this field
    [[+myFile]]


    I hope this help.

    I believe natedin wants to attach a file from the server and not submitted by form. His problem seems to be a path setting.
      Codeplaza Webdesign: for professional websites at low cost
      • 38783
      • 571 Posts
      I just stumbled across this old link whilst searching for the solution to a completely different problem. It may be relevant:

      https://forums.modx.com/index.php?action=thread&thread=58712&i=1
        If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

        email: [email protected] | website: https://andytough.com
        • 44649
        • 68 Posts
        Thanks for the suggestion DonQuicky, but yeah was looking to attach a file from the server.

        I've managed to get it working after reinstalling a new fresh version of modx on a linux server and playing with the path (the control panel path was different than what the documentation said), but the localhost server path was correct but still doesn't work for some reason.

        Anyway, it's working on the live site now; thanks for the help guys!

        For anyone else looking, this is the attachment snippet on Plesk 17.0.17 (Onyx):
        <?php
        $attachment = '/var/www/vhosts/website.com/sub.website.com/assets/uploads/picture.jpg';
        $hook->modx->getService('mail', 'mail.modPHPMailer');
        $hook->modx->mail->mailer->AddAttachment($attachment);
        return true;
          • 53387
          • 2 Posts
          Hey.
          I use the same code to attach a file to a letter.

          $attachment = 'assets/....pdf';
          $basepath = $modx->getOption('base_path');
          $hook->modx->getService('mail', 'mail.modPHPMailer');
          $hook->modx->mail->mailer->AddAttachment($basepath.$attachment);		
          


          On my mail comes a letter with an attached file, and on the client's mail without.
          I then add this line

          $hook->modx->mail->address('to', $curEmail);


          And then the client receives two letters. With the attached file and without.
          Help me please.