2

我正在研究一个解析电子邮件收件箱的脚本。如何判断消息部分是附件还是嵌入图像?此示例邮件是由一位用户发送的,他告诉我他的客户嵌入了图像,但 disposition="Attachment" 看起来像附加图像,我看到 AppleMail 使用“内联”,这似乎更合理......

我还检查了 msg-text 以查看它是否引用了附加的文件,但在这个示例中也没有对文件的引用——但用户坚持认为它们是嵌入的,而不是附加的。

消息结构:

object(stdClass)#218 (12) {
  ["type"]=>
  int(1)
  ["encoding"]=>
  int(0)
  ["ifsubtype"]=>
  int(1)
  ["subtype"]=>
  string(5) "MIXED"
  ["ifdescription"]=>
  int(0)
  ["ifid"]=>
  int(0)
  ["bytes"]=>
  int(262312)
  ["ifdisposition"]=>
  int(0)
  ["ifdparameters"]=>
  int(0)
  ["ifparameters"]=>
  int(1)
  ["parameters"]=>
  array(1) {
    [0]=>
    object(stdClass)#219 (2) {
      ["attribute"]=>
      string(8) "BOUNDARY"
      ["value"]=>
      string(37) "----_=_NextPart_001_01CE168A.AE40BD2E"
    }
  }
  ["parts"]=>
  array(5) {
    [0]=>
    object(stdClass)#220 (12) {
      ["type"]=>
      int(1)
      ["encoding"]=>
      int(0)
      ["ifsubtype"]=>
      int(1)
      ["subtype"]=>
      string(11) "ALTERNATIVE"
      ["ifdescription"]=>
      int(0)
      ["ifid"]=>
      int(0)
      ["bytes"]=>
      int(4237)
      ["ifdisposition"]=>
      int(0)
      ["ifdparameters"]=>
      int(0)
      ["ifparameters"]=>
      int(1)
      ["parameters"]=>
      array(1) {
        [0]=>
        object(stdClass)#221 (2) {
          ["attribute"]=>
          string(8) "BOUNDARY"
          ["value"]=>
          string(37) "----_=_NextPart_002_01CE168A.AE40BD2E"
        }
      }
      ["parts"]=>
      array(2) {
        [0]=>
        object(stdClass)#222 (12) {
          ["type"]=>
          int(0)
          ["encoding"]=>
          int(4)
          ["ifsubtype"]=>
          int(1)
          ["subtype"]=>
          string(5) "PLAIN"
          ["ifdescription"]=>
          int(0)
          ["ifid"]=>
          int(0)
          ["lines"]=>
          int(21)
          ["bytes"]=>
          int(204)
          ["ifdisposition"]=>
          int(0)
          ["ifdparameters"]=>
          int(0)
          ["ifparameters"]=>
          int(1)
          ["parameters"]=>
          array(1) {
            [0]=>
            object(stdClass)#223 (2) {
              ["attribute"]=>
              string(7) "CHARSET"
              ["value"]=>
              string(10) "iso-8859-1"
            }
          }
        }
        [1]=>
        object(stdClass)#224 (12) {
          ["type"]=>
          int(0)
          ["encoding"]=>
          int(4)
          ["ifsubtype"]=>
          int(1)
          ["subtype"]=>
          string(4) "HTML"
          ["ifdescription"]=>
          int(0)
          ["ifid"]=>
          int(0)
          ["lines"]=>
          int(97)
          ["bytes"]=>
          int(3709)
          ["ifdisposition"]=>
          int(0)
          ["ifdparameters"]=>
          int(0)
          ["ifparameters"]=>
          int(1)
          ["parameters"]=>
          array(1) {
            [0]=>
            object(stdClass)#225 (2) {
              ["attribute"]=>
              string(7) "CHARSET"
              ["value"]=>
              string(10) "iso-8859-1"
            }
          }
        }
      }
    }
    [1]=>
    object(stdClass)#226 (14) {
      ["type"]=>
      int(5)
      ["encoding"]=>
      int(3)
      ["ifsubtype"]=>
      int(1)
      ["subtype"]=>
      string(3) "BMP"
      ["ifdescription"]=>
      int(1)
      ["description"]=>
      string(7) "bmp.bmp"
      ["ifid"]=>
      int(0)
      ["bytes"]=>
      int(191348)
      ["ifdisposition"]=>
      int(1)
      ["disposition"]=>
      string(10) "ATTACHMENT"
      ["ifdparameters"]=>
      int(1)
      ["dparameters"]=>
      array(1) {
        [0]=>
        object(stdClass)#227 (2) {
          ["attribute"]=>
          string(8) "FILENAME"
          ["value"]=>
          string(7) "bmp.bmp"
        }
      }
      ["ifparameters"]=>
      int(1)
      ["parameters"]=>
      array(1) {
        [0]=>
        object(stdClass)#228 (2) {
          ["attribute"]=>
          string(4) "NAME"
          ["value"]=>
          string(7) "bmp.bmp"
        }
      }
    }
    [2]=>
    object(stdClass)#229 (14) {
      ["type"]=>
      int(5)
      ["encoding"]=>
      int(3)
      ["ifsubtype"]=>
      int(1)
      ["subtype"]=>
      string(3) "GIF"
      ["ifdescription"]=>
      int(1)
      ["description"]=>
      string(7) "gif.gif"
      ["ifid"]=>
      int(0)
      ["bytes"]=>
      int(12178)
      ["ifdisposition"]=>
      int(1)
      ["disposition"]=>
      string(10) "ATTACHMENT"
      ["ifdparameters"]=>
      int(1)
      ["dparameters"]=>
      array(1) {
        [0]=>
        object(stdClass)#230 (2) {
          ["attribute"]=>
          string(8) "FILENAME"
          ["value"]=>
          string(7) "gif.gif"
        }
      }
      ["ifparameters"]=>
      int(1)
      ["parameters"]=>
      array(1) {
        [0]=>
        object(stdClass)#231 (2) {
          ["attribute"]=>
          string(4) "NAME"
          ["value"]=>
          string(7) "gif.gif"
        }
      }
    }
    [3]=>
    object(stdClass)#232 (14) {
      ["type"]=>
      int(5)
      ["encoding"]=>
      int(3)
      ["ifsubtype"]=>
      int(1)
      ["subtype"]=>
      string(4) "JPEG"
      ["ifdescription"]=>
      int(1)
      ["description"]=>
      string(7) "jpg.jpg"
      ["ifid"]=>
      int(0)
      ["bytes"]=>
      int(25642)
      ["ifdisposition"]=>
      int(1)
      ["disposition"]=>
      string(10) "ATTACHMENT"
      ["ifdparameters"]=>
      int(1)
      ["dparameters"]=>
      array(1) {
        [0]=>
        object(stdClass)#233 (2) {
          ["attribute"]=>
          string(8) "FILENAME"
          ["value"]=>
          string(7) "jpg.jpg"
        }
      }
      ["ifparameters"]=>
      int(1)
      ["parameters"]=>
      array(1) {
        [0]=>
        object(stdClass)#234 (2) {
          ["attribute"]=>
          string(4) "NAME"
          ["value"]=>
          string(7) "jpg.jpg"
        }
      }
    }
    [4]=>
    object(stdClass)#235 (14) {
      ["type"]=>
      int(3)
      ["encoding"]=>
      int(3)
      ["ifsubtype"]=>
      int(1)
      ["subtype"]=>
      string(12) "OCTET-STREAM"
      ["ifdescription"]=>
      int(1)
      ["description"]=>
      string(7) "pdf.pdf"
      ["ifid"]=>
      int(0)
      ["bytes"]=>
      int(27834)
      ["ifdisposition"]=>
      int(1)
      ["disposition"]=>
      string(10) "ATTACHMENT"
      ["ifdparameters"]=>
      int(1)
      ["dparameters"]=>
      array(1) {
        [0]=>
        object(stdClass)#236 (2) {
          ["attribute"]=>
          string(8) "FILENAME"
          ["value"]=>
          string(7) "pdf.pdf"
        }
      }
      ["ifparameters"]=>
      int(1)
      ["parameters"]=>
      array(1) {
        [0]=>
        object(stdClass)#237 (2) {
          ["attribute"]=>
          string(4) "NAME"
          ["value"]=>
          string(7) "pdf.pdf"
        }
      }
    }
  }
}
4

2 回答 2

3

通过 [ifid] 检查图像是否内联的最佳方法。我检查了各种邮件应用程序。他们以不同的方式处理内联附件。Zoho Mail 标志着

[处置] => 内联

实时邮件标记

[处置] => 附件

两人都设

[ifid] => 1 [id] => <0.28876465441.6812139177583476518.150d8a30c19__inline__img__src>

如果[ifid] => 1那么它是一个内联图像,[id] 将是图像 cid。下载内联附件并替换

src="cid:0.28876465441.6812139177583476518.150d8a30c19__inline__img__src"

与下载的路径

于 2015-11-05T17:48:26.417 回答
1

嵌入图像将是“多部分/相关”类型的 MIME 正文部分的第二个和后续子代。附加图像将是“multipart/mixed”类型的 MIME 正文部分的子项。

于 2013-03-10T19:59:54.790 回答