Frage

Ich bin eine E-Mail an einen api sendet, dessen Inhalt von einer angehängten Datei wird.

Ich will nicht wirklich die Datei erstellen (es ist wie eine Textzeile) und dann anhängen und versenden.

Ist es möglich, einen Filestream zu erstellen und dass durch Swiftmailer senden?

War es hilfreich?

Lösung

Turns out Swiftmailer supports Dynamic Attachments.

The basic idea is:

//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);

Hope this helps someone out there.

Andere Tipps

I have always had to create the file and then attach it with SwiftMailer.

Though you can unlink() the file as soon as the email has been sent.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top