PHP mail() attachment is corrupt

后端 未结 3 1565
Happy的楠姐
Happy的楠姐 2021-01-25 16:00

I have been struggling with trying to send an email with an attachment using PHP. It used to work but the message body was scrambled. Now I have got the message body to work but

相关标签:
3条回答
  • 2021-01-25 16:40

    I would suggest looking at phpmailer if you want to do complex email.

    0 讨论(0)
  • 2021-01-25 16:40

    I could be wrong but I believe you will have to encode the PDF somehow, 7bit won't work as the PDF file will have content outside the range. Why not use base64 for the PDF?

    0 讨论(0)
  • 2021-01-25 16:49

    I know you've said about pre-built classes but there is a reason that people do this - why re-invent the wheel? I use SwiftMailer for projects - it couldn't be simpler. See this SwiftMailer example for 13 lines (including some blank ones) of how to create a message, add an attachment and send.

    As to the resolution of your actual query, upvote to Josh's answer - I'd second changing the encoding and seeing how you get on. Have you tried getting an example email message which has an attachment that works, and examining the raw data?

    0 讨论(0)
提交回复
热议问题