PDA

View Full Version : pdf attachments in php mail?



houjenming
09-18-2009, 01:23 PM
Hello,

I'm trying to email pdf attachments in a php script. On my current host (i'm trying to migrat to bluehost from another), it works fine.

the "from" address is valid, and php's mail() function can properly send typical emails out (after i added the from: email address to my mail settings).

I even checked to make sure that the php mail() function is returning true when it's sending the email. That seems to be okay, but no email is received - not in spam filter, either.

Does bluehost block outgoing emails with attachments?

Thanks for your help,

j

felgall
09-18-2009, 03:01 PM
Does bluehost block outgoing emails with attachments?

No they don't. I have several PHP generated emails with a variety of attachments and they all send fine. There are a few destinations that dump them into spam folders and such but that is due to the destination filtering being set up incorrectly.

houjenming
09-18-2009, 03:33 PM
Problem found.

Here's the problem: be careful about having spaces in the "Content-Disposition:" of your attachment.

i had a pdf with this name: "xxxx.com Quote Q-02092009-2332-I.pdf"

so, in the raw body of the email, there was this line:

Content-Disposition: attachment; filename="xxxx.com Quote Q-02092009-2332-I.pdf"

it turns out that when sending *FROM BLUEHOST*, gmail doesn't like the attachment because it thinks that the file is called xxxx.com, which could be an (windows) executable file which could be a virus/malicious file. The space in the filename is what causes gmail to not see the file's full name. Strange that this doesn't happen when sending from my old host. gmail doesn't mind the space in the filename then.

the solution: replace spaces with underscores in the php script that actually does the attaching and sending of the email.

thanks for your reply, felgall .