How can I attach multiple pdfs to drupal_mail() function? Was doing something like this

        global $base_url;
        $uri = $base_url . '/sites/default/files/test.pdf';
        if(!empty($mail_content)) {
            /*send mail */
            $to =$mail_content['to'];       //gets the current user's mail address
            $from = variable_get('site_mail', '');    //admin's mail address
            $body = $mail_content['body'];

            $filemime = $mail_content['mime'];
            $filename = $mail_content['filename'];
            //$filepath = 
            //$filealtname  = drupal_basename($filearray['uri'], $suffix = NULL);

                $attachment = array(
                'filecontent' =&gt; 'http://localhost/cando/sites/default/files/test.pdf',
                'filename' =&gt; $filename,
                'filemime' =&gt; $filemime,
            ); 

            $mail_content['params']['attachments'][] = $attachment;
            $params = array(
                'subject' =&gt; $mail_content['subject'],
                'body' =&gt; $body,
                'attachment'=&gt;$attachment,
            );

             // print_r($attachment);print_r($params);exit;
        //  print_r(file_get_contents(DRUPAL_ROOT));die;
            $message = drupal_mail('cando_custom', $mail_content['mkey'], $to, language_default(),$params,$from); 

            return 'Mail Sent ... ';

        }
    }
You forgot to add headers to the params array.

I did something like :

$attachment = array(
      'filecontent' =&gt; $filepathname,
      'filename' =&gt; $namefile,
      'filemime' =&gt; 'application/pdf'
      );
//where $filepathname should contain the path to the file and $filename should contain the name of the file.

$params = array(
  'headers' =&gt; array('Content-Type' =&gt; 'text/html'),
  'key' =&gt; 'test',
  'to' =&gt; 'test@example.com',
  'from' =&gt; 'test@example.com',
  'subject' =&gt; 'Test email',
  'body' =&gt; 'test',
  'attachment' =&gt; $attachment
);

drupal_mail($module, $key, $to, $language, $params, $from, $send);


which worked for me.

In your case:


Check the value of $filemime variable.
Add headers to the code.