从 MySQL 查询传递到 Mail_mimeDecode() 的电子邮件的附件字符有误

发布于 2024-11-14 12:17:11 字数 3000 浏览 5 评论 0原文

我们有一个数据库,其中存储了 mbox 格式的电子邮件、邮箱格式的原生 base64 格式的附件。我们可以检索和访问/解析所有信息......除了附件。简而言之,我可以进入 MySQL 并实际看到 base64_encoded 附件数据,但无论出于何种原因 Mail_mimeDecode() 结构显示附件部分如下:

[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
)

有什么想法吗?也许这是我存储它的方式,但如果这是真的,那么在 phpMyAdmin 中编辑行时我将无法看到实际的 base64 数据。正是因为这个原因,我怀疑发生了其他事情。

其他信息

  1. 我将排序规则设置为:utf8_bin,所以 不区分大小写
  2. 我设置的 存储消息的列类型 为长文本,所以有足够的空间 保存大多数消息

更新信息

添加在decode()函数中建议的标志让我得到了一个看起来是base64的字符串,但它只是字符串的一部分。作为测试,我尝试从名为“test.mbox”的文件(而不是 MySQL)加载完全相同的消息。通过文件加载效果很好,并向我展示了一切,但是当通过 MySQL 加载时,我只看到了这一点。就像它截断了它并只显示其中一个附件(此消息中有两个)。

[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
)

...实际上,它应该看起来像这样(来自我运行的“test.box”测试):

[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
)

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 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
)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撕心裂肺的伤痛 2024-11-21 12:17:11

惊喜! Mail_mimeDecode 实际上,好吧,我犹豫着要不要说,解码附件。

顺便说一句:长文本保存大多数电子邮件消息是轻描淡写的,我希望是 4GB,我不想收到比这更大的邮件:)

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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文