Swiftmailer ::发送虚拟文件?
-
10-10-2019 - |
题
我将电子邮件发送给API,该电子邮件从附加的文件中获取其内容。
我不想实际创建文件(它就像一行文本),然后将其连接并发送。
是否可以创建文件流并通过SwiftMailer发送?
解决方案
基本思想是:
//Create your content in a variable.
$content = "Hi there\r\nHow are you";
//Create a Swiftmailer attachment
//specify the data, filename, mimetype
$attachment = Swift_Attachment::newInstance($content, 'my-file.pdf', 'application/pdf');
//attach the file
$message->attach($attachment);
希望这对某人有帮助。
其他提示
我一直必须创建文件,然后将其与SwiftMailer一起附加。
虽然可以 unlink()
电子邮件发送后立即该文件。
不隶属于 StackOverflow