正如我们在下面看到的那样,没有任何方法被调用,getAttachments()
那么我如何通过Swift_Message
对象列出/获取/循环来附件?我在文档或示例中找不到任何信息.下面列出了所有方法如下,文档在这里.我可以检查除附件之外的所有其他内容.
我正在使用symfony来做到这一点.
Array ( [0] => __construct [1] => newInstance [2] => addPart [3] => attachSigner [4] => detachSigner [5] => toString [6] => toByteStream [7] => __wakeup [8] => __clone [9] => getNestingLevel [10] => setSubject [11] => getSubject [12] => setDate [13] => getDate [14] => setReturnPath [15] => getReturnPath [16] => setSender [17] => getSender [18] => addFrom [19] => setFrom [20] => getFrom [21] => addReplyTo [22] => setReplyTo [23] => getReplyTo [24] => addTo [25] => setTo [26] => getTo [27] => addCc [28] => setCc [29] => getCc [30] => addBcc [31] => setBcc [32] => getBcc [33] => setPriority [34] => getPriority [35] => setReadReceiptTo [36] => getReadReceiptTo [37] => attach [38] => detach [39] => embed [40] => __toString [41] => setBody [42] => getCharset [43] => setCharset [44] => getFormat [45] => setFormat [46] => getDelSp [47] => setDelSp [48] => charsetChanged [49] => generateId [50] => getHeaders [51] => getContentType [52] => setContentType [53] => getId [54] => setId [55] => getDescription [56] => setDescription [57] => getMaxLineLength [58] => setMaxLineLength [59] => getChildren [60] => setChildren [61] => getBody [62] => getEncoder [63] => setEncoder [64] => getBoundary [65] => setBoundary [66] => encoderChanged [67] => __destruct )
我可以确认该对象包含附件.转储结果:
toString()输出
.... .... --_=_swift_v4_1449763083_6fe131190f5a7df1b45687b6bbb117a9_=_ Content-Type: image/jpeg; name=38423961aa437473ae2d6cb8caf796d31e20dbc4.jpeg Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=38423961aa437473ae2d6cb8caf796d31e20dbc4.jpeg /9j/4AAQSkZJRgABAgEAYABgAAD/4RCIRXhpZgAATU0AKgAAAAgAA4dpAAQAAAABAAAIPpyeAAEA .... ....
var_export()输出
Swift_Message::__set_state(array( 'headerSigners' => array ( ), .... .... array ( 'filename' => '38423961aa437473ae2d6cb8caf796d31e20dbc4.jpeg', ), .... ....
qooplmao.. 8
从代码看起来,附件被添加到$_children
(from Swift_Mime_SimpleMimeEntity
)数组中.
public function attach(Swift_Mime_MimeEntity $entity) { $this->setChildren(array_merge($this->getChildren(), array($entity))); return $this; }
这让我相信你可以使用所有的附件->getChildren()
.
从代码看起来,附件被添加到$_children
(from Swift_Mime_SimpleMimeEntity
)数组中.
public function attach(Swift_Mime_MimeEntity $entity) { $this->setChildren(array_merge($this->getChildren(), array($entity))); return $this; }
这让我相信你可以使用所有的附件->getChildren()
.