0

I'm trying to attach a file to an email. It's part of job application so a person goes to a node, presses apply and it sends an email to the creator of the node. I want to attach a CV & cover letter to it.

The problem is I'm storing the CV & cover letter in a private folder outside of drupal root. (Personal info security and all that.) The code below works for public folders. How would I got about altering it to access private ones?

function tellafriend_mail($key, &$message, $params) {

        global $base_url;

        $message['subject'] = t('Your friend thought you might like this site');

        $message['body'][] = t("Hello,\nYour friend thought you might like this site.  Please click the link below to visit.\n\n!link", array('!link' => $base_url));
        $attachment = array(
          'filecontent' => file_get_contents('http://localhost/private/counciltax.txt'),    
          'filename' => 'test.txt',
          'filemime' => 'textplain',
        );
        $message['params']['attachments'][] = $attachment;
   }
0

You can use the drupal private file directory notation:

file_get_contents('private://counciltax.txt')
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.