Pregunta

Estoy enviando un correo electrónico a un API que obtiene su contenido desde un archivo adjunto.

No quiero realmente crear el archivo (que es como una línea de texto) y luego adjuntarlo y enviarlo.

¿Es posible crear un filestream y enviar que a través de SwiftMailer?

¿Fue útil?

Solución

SwiftMailer apoya dinámicos adjuntos .

La idea básica es la siguiente:

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

Espero que esto ayude a alguien por allí.

Otros consejos

Siempre he tenido que crear el archivo y luego adjuntarlo con SwiftMailer.

A pesar de que puede unlink() el archivo tan pronto como el correo electrónico ha sido enviado.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top