H!

I'm using mimemail for sending mails with attachments but when i receive my mail, the attachment, a pdf file, seems to be broken or damaged...
On my server the files do are correct...

Does anybody knows what could be wrong?

Thx!

Comments

sgabe’s picture

Please give us more details:

  • how do you generate the message (Rules, Simplenews, Webform etc.)
  • the files are damaged or broken in what way? (cannot be opened, defect in the content etc.)
Joni Haeck’s picture

I just use php to generate the mail.

I the body of a page i type:

'


header('Location: aanmaakpdf/facturenperopdracht/confirmed/2011.pdf');

$sender = 'test@example.com';
$recipient = 'test@example.com';
$subject = 'New order';
$body = 'Please, see the attachment.';
$plaintext = TRUE;
$headers = array();
$attachments[] = array(
  'filepath' => 'aanmaakpdf/facturenperopdracht/confirmed/2011.pdf',
  'filemime' => 'mime/type',
  'filename' => '2011 Mar-AC Partners.pdf',
  'list' => TRUE,
);

mimemail($sender, $recipient, $subject, $body, $plaintext, $headers, $text = NULL, $attachments, $mailkey);

'

On my mac, when i try to open the attachment i received in the mail, it gives me an error saying the file is broken and could not be opened...

sgabe’s picture

The correct MIME type for a PDF file is application/pdf.

Is the file encoded in the message? (Can you see it in the message source?)

Joni Haeck’s picture

I made the change but it still occurs...

I don't know how to see if the file is encoded in the message...

sgabe’s picture

You can check it with a desktop mail client.

Joni Haeck’s picture

I'm using 'Mail' for mac... i can't find the source code...

Joni Haeck’s picture

Okay i did find it after all... It's in the Content-Disposition: attachment; filename="2011.pdf"

What now?

Joni Haeck’s picture

Anybody?

pgrond’s picture

What is wrong with the Content-Disposition? Is attachment not right?
I'm having also some problems with sending attachments. Gmail perfectly recognizes the attachment, but the iPad for example not.

RedHead’s picture

try to add into webform.submissions.inc in 273:
$message['attachments'] = $attachments;

272     $message = drupal_mail('webform', 'submission', $address, $language, $mail_params, $email['from'], FALSE);
273        // Hack for attachments sending 
274       $message['attachments'] = $attachments;
275       $message = mimemail($message['from'], $message['to'], $message['subject'], $message['body'], !$email['html'], $message['headers'], $email['html'] ? NULL : $message['body'], $message['attachments'], 'webform');
yesct’s picture

regarding #10, I think the new version, 3.12, of webform fixed the need for that hack by using $mail_params['attachments'] = $attachments;

(but I can't get it configured to send attachments... I'm looking for documentation on how to do that).

trevorbradley’s picture

I just hit this myself, using the rules module. (mimemail-1.0 here)

I've set my attachment as the following:

image/png:/var/www/sites/default/files/grinch_0.png

It's a simple image and is fine on the server before sending.

The png is corrupted if sent to either thunderbird or Outlook 2010. The filesize appears similar (differing by 21 bytes out of 720k) but looking at it with a hex editor it appears profoundly mangled...

Aha! Got it... the base64 is mangled:

Original, uncorrupted, from email source:

Content-Type: image/png;
 name="grinch.png"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="grinch.png"

iVBORw0KGgoAAAANSUhEUgAAAogAAANwCAYAAACs/5t6AAAAAXNSR0IArs4c6QAAAAZiS0dE
AAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sMDRYhDWkyxQwAACAA
SURBVHja7L152OVXVSW89q2qtzLPCSRknggJIUZGGQIBFIjMQwDBFhAbCSCar5FPaaW1wRbE

Corrupted file:

Content-Type: application/octet-stream; name="grinch_0.png"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="grinch_0.png"

ContentTransferEncodingbase64iVBORw0KGgoAAAANSUhEUgAAAogAAANwCAYAAACs/5t6AAA
AAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1
FB9sMDRYhDWkyxQwAACAASURBVHja7L152OVXVSW89q2qtzLPCSRknggJIUZGGQIBFIjMQwDBFhA

So the string "ContentTransferEncodingbase64" is somehow squeaking into the file data.

Investigating...

EDIT: This looks like a bug with the SMTP Authentication module: http://drupal.org/node/1189940

sgabe’s picture

Status: Active » Closed (duplicate)

This seems to be a duplicate of #1391736: Corrupted attachment via SMTP.