Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php $message->;toString()导致错误,无法打开文件_Php_Yii2_Swiftmailer_Codeception - Fatal编程技术网

Php $message->;toString()导致错误,无法打开文件

Php $message->;toString()导致错误,无法打开文件,php,yii2,swiftmailer,codeception,Php,Yii2,Swiftmailer,Codeception,我正在尝试从codeception内部的电子邮件中检索附件名称 发送电子邮件后,将创建CSV文件,然后将其删除 如果删除该文件,则$message->toString()返回与该文件相关的数据字符串 有没有办法在不打开文件的情况下直接获取文件名?您可以查看swiftmailer中提供的Swift\u Mime\u附件类。yii2在Message::attach()中调用Swift\u Attachment类,该类扩展了Swift\u Mime\u Attachment,您可能需要扩展yii\sw

我正在尝试从codeception内部的电子邮件中检索附件名称

发送电子邮件后,将创建CSV文件,然后将其删除

如果删除该文件,则
$message->toString()
返回与该文件相关的数据字符串


有没有办法在不打开文件的情况下直接获取文件名?

您可以查看swiftmailer中提供的
Swift\u Mime\u附件
类。yii2在
Message::attach()
中调用
Swift\u Attachment
类,该类扩展了
Swift\u Mime\u Attachment
,您可能需要扩展
yii\swiftmailer\Message
类并重写
attach
方法来保存
Swift\u附件的实例,然后通过Message类使用它来调用
Swift\u附件::getAttachment()
返回附件的文件名,使用标题
'content-disposition','filename'
。从未尝试过,但如果我正在尝试的话,我会想到这一点