Page 1 of 1

Attach word doc with Swift mailer

Posted: Wed Sep 27, 2006 4:47 pm
by jo

Code: Select all

$mailer->addAttachment(file_get_contents($file), $name, 'application/msword');
The above code is the raw string I am tring to use, and I can get images to work and pdf docs, but anytime I try word docs such as here, the attachment shows in the email but when you open it it is blank, any suggestions?

Jo

Posted: Wed Sep 27, 2006 4:54 pm
by Chris Corbyn
Can you show us the rest of the code where $name etc comes from? Technically one file format is the same as any other so there shouldn;t be a difference if one works.

Hopefully not to sound patronising but I assume you've opened the same word document on the server and found it be ok? :)

Posted: Wed Sep 27, 2006 4:58 pm
by volka
Does your mail client show you the size of the attachment?
Does your script test the existence of the file and its size?

Code: Select all

$doc_data = file_get_contents($file);
$mailer->addAttachment($doc_data, $name, 'application/msword');

echo '<div>Debug - file:', $file, ', size:', strlen($doc_data), "</div>\n";