SwiftMailer ::仮想ファイルを送信しますか?
-
10-10-2019 - |
質問
添付ファイルからコンテンツを取得するAPIにメールを送信しています。
ファイルを実際に作成して(1つのテキストのようなテキスト)、それを添付して送信したくありません。
Filestreamを作成し、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);
これが誰かを助けてくれることを願っています。
他のヒント
私は常にファイルを作成してから、SwiftMailerで添付する必要がありました。
あなたはできますが unlink()
メールが送信されるとすぐにファイル。
所属していません StackOverflow