gpt4 book ai didi

php - 从 Swift_Message 对象获取附件列表

转载 作者:可可西里 更新时间:2023-11-01 13:14:22 26 4
gpt4 key购买 nike

正如我们在下面看到的,没有任何名为 getAttachments() 的方法,所以我如何列出/获取/循环遍历 Swift_Message 对象的附件?我在文档或示例中找不到任何信息。下面列出了所有方法和 doc is here 。我可以检查除附件之外的所有其他内容。

我正在使用 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',
),
....
....

最佳答案

来自 the code看起来附件已添加到 $_children(来自 Swift_Mime_SimpleMimeEntity)数组。

public function attach(Swift_Mime_MimeEntity $entity)
{
$this->setChildren(array_merge($this->getChildren(), array($entity)));

return $this;
}

这让我相信您可以使用 ->getChildren() 获取所有附件。

关于php - 从 Swift_Message 对象获取附件列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34207766/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com