Hello I am using SwiftMailer on Symfony2, I can send emails successfuly, but now i am first making a pdf, then attaching at the mail, sending and finally deleting the pdf file.
here is my code.
$pdf->Output('cuestionario/attach/' . $nombre . '.pdf', 'F');
$correosFinal = array();
foreach ($correos as $correo) {
$correosFinal[$correo->getId()] = $correo->getCorreo();
}
$message = Swift_Message::newInstance()
->setSubject($respuesta['nombre'])
->setFrom($this->container->getParameter('mailer_user'))
->setTo($correosFinal)
->setBody($html, 'text/html')
->attach(Swift_Attachment::fromPath(
'cuestionario/attach/' . $nombre
. '.pdf'));
$enviado = $this->get('mailer')->send($message);
if ($enviado) {
unlink('cuestionario/attach/' . $nombre . '.pdf');
}
The trouble is that I am deleting the file so fast that the mail say sent but hit dont really is sent....