MimeMail PHP sender: issue with attachments

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aneuryzma
Forum Contributor
Posts: 106
Joined: Sat May 17, 2008 7:03 am

MimeMail PHP sender: issue with attachments

Post by aneuryzma »

hi,

I'm using mimemail module in Drupal to send e-mails with attachments. The e-mails are correctly sent, but the attachments not. This is the code I use (I've just enabled the module):

Code: Select all

$sender = 'mycompany@company.com';
$recipient = 'myemail@mail.com';
$subject = 'New order';
$body = 'Please, see the attachment.';
$plaintext = TRUE;
$headers = array();
$attachments[]=array(
'filepath' => 'invoices/sample.pdf',
'filemime' => 'application/pdf',
);
mimemail($sender, $recipient, $subject, $body, $plaintext, $headers, $text = NULL, $attachments, $mailkey);

In order to be sure the path to the pdf attachment is correct I've written this line to download the attachment from browser and it works.

Code: Select all

header('Location: invoices/sample.pdf');
I've also tried absolute paths such as:
/invoices/sample.pdf
http://www.mydomain.com/invoices/sample.pdf

Also,I've tried this alternative code. But still nothing...

Code: Select all

$file = new stdClass();
$file->filename = 'sample.pdf';
$file->filepath = 'invoices/sample.pdf';
$file->filemime = 'application/pdf';
mimemail($sender, $recipient, $subject, $body, $plaintext, $headers, $text = NULL, array($file), $mailkey);
ps. i don't think this, but is maybe because my hosting disallow to send attachments ?
thanks
Post Reply