开发者

Email passed to Mail_mimeDecode() from MySQL query has goofed up characters for attachments

We have a database with stored mbox formatted emails, attachments in their native base64 format in the mailbox format. We can retrieve and access/parse all information...except for the attachments. In short, I can go into MySQL and actually see base64_encoded attachment data, but for whatever reason Mail_mimeDecode() structure shows the attachment portion like this:

[1] => stdClass Object
(
    [headers] => Array
    (
        [content-type] => image/gif; name="image.gif"
        [content-id] => <3243498760_6337281>
        [content-transfer-encoding] => base64
    )

    [ctype_primary] => image
    [ctype_secondary] => gif
    [ctype_parameters] => Array
    (
        [name] => image.gif
    )

    [body] => GIF89ahôÐÐÐðððÙÙ@àààòòÀ   ```000ßß`   PP
)

Any thoughts? Maybe it's the way I'm storing it, but if that were true, then I wouldn't be able to 开发者_JS百科see actual base64 data when editing a row in phpMyAdmin. It's for that reason I'm suspecting something else happening.

Additional Information

  1. I set the collation to: utf8_bin, so it's not case insensitive
  2. I set the column type for the stored message to longtext, so there's enough space to hold most messages

Updated Information

Adding the flags suggested in the decode() function got me a base64 looking string, but it's only part of the string. As a test, I tried loading the exact same message from a file called "test.mbox" as opposed to MySQL. The loading via file worked great and showed me everything, but when doing it via MySQL I only see this. It's like it's truncating it and only shows one of the attachments (there are two in this message).

[1] => stdClass Object
(
    [headers] => Array
    (
        [content-type] => image/gif; name="image.gif"
        [content-id] => <3243498760_6337281>
        [content-transfer-encoding] => base64
    )

    [ctype_primary] => image
    [ctype_secondary] => gif
    [ctype_parameters] => Array
    (
        [name] => image.gif
    )

    [body] => R0lGODlhaAATAPQAANDQ0PDw8BAQENnZQODg4PLywCAgIGBgYDAwMN/fYKCgoJCQkFBQU
)

...when in actuality, it should look like this (from the "test.box" test I ran):

[1] => stdClass Object
(
    [headers] => Array
    (
        [content-type] => image/gif; name="image.gif"
        [content-id] => <3243498760_6337281>
        [content-transfer-encoding] => base64
    )

    [ctype_primary] => image
    [ctype_secondary] => gif
    [ctype_parameters] => Array
    (
        [name] => image.gif
    )

    [body] => R0lGODZhaAATAPQAANDQ0PDw8BAQENnZQODg4PLywCAgIGBgYDAwMN/fYKCgoJCQkFBQUHBw
cObmgM/PEPz88LCwsPn54ZzsoPb20O/vsICAgEBAQMDAwMzMAAAAAP///wAAAAAAAAAAAAAA
ACH/C01TT0ZGSUNFOS4wGAZAAAxtc09QTVNPRkZJQ0U5LjAgJPn1cgAh/wtNU09GRklDRTku
MBgAAAAMY21QUEpDbXAwNzEyZAAAA0gAc7wALAAAAABoABMAAAX/4CaOZGmeJIYRKElgQCvP
Y6DSeC5jmnbRl55uKLL0MMQkjucjWSyKUlCTegaUJqMGie2amL9RLzxqXMibKde70a7ZXjBp
DDzC2/ahpMDv+wsSJgAqhDcjchsqPZgqMRuDXC8IPQuGNiskkCWFGAd5IpCEjiQOGaanqBkD
JlM9rggsiXQbrrVhU0W1rkhMFiRTjgACursiAZPEBxs2ACwJqamrUsQ9DCKI1LdCeMS8Pb4j
aiIG1HmtxDEWAmHPqQ+m0iQRT/QMrtezCloGT1y4jxbIaThgYcGVXr/sMOFHDxkXV/TU2SEA
YFQ7VRVKqZqxoBa+JmJAhtsmQtyhbwm3/8gSye3htgCtYplIMKDABgjvNqIIYM/jSjSzRlIR
+gYh0Z9O8tzDMKxHFBoadQoS6BORiKZlSab5tBJcVpVWW16l5ErAmxY4T8Uj0bGH2XtIQ6LZ
OvRrUZSgmnoTSUCgS1tXcExAtVaEpzFX4IbFSjflXQ3g2iqcFaGpSlq1vOa4WBgAxJBDF7Ns
fPQkZJ669v5okHqsBrNK2hVeSI/1NtGQoXwlcZiBlZUIqOpdKQDZa6U9CEa0EJjGs9nlbmOl
CvKfCAWtmZTFYNKyUzeGo5+VQdOEcV1hmFgbAYCqtroibNvx7OrCFWDXm15IlyfA4W5DUHBC
KIWkgEFz7KkQyxcLo9TQyAgvwAChhJnIdEkJlxTS4AYhAAA7
)


Surprise! Mail_mimeDecode actually, well, I hesitate to say it, decodes the attachment.

BTW: longtext holding most email messages is an understatement I hope, that's 4GB, would hate to receive a mail bigger than that :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜