Email swiftmailer::发送虚拟文件?

Email swiftmailer::发送虚拟文件?,email,file,swiftmailer,Email,File,Swiftmailer,我正在向一个api发送一封电子邮件,该api从附件中获取其内容 我不想实际创建文件(类似于一行文本),然后附加并发送它 是否可以创建一个文件流并通过swiftmailer发送?我一直需要创建文件,然后用swiftmailer附加它 尽管您可以在电子邮件发送后立即取消链接()。 基本思想是: //Create your content in a variable. $content = "Hi there\r\nHow are you"; //Create a Swiftmailer attac

我正在向一个api发送一封电子邮件,该api从附件中获取其内容

我不想实际创建文件(类似于一行文本),然后附加并发送它


是否可以创建一个文件流并通过swiftmailer发送?

我一直需要创建文件,然后用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);

希望这对其他人有所帮助。

好消息是,我找到了答案:+1很高兴你找到了答案,我以后会检查:)