title: Swiftmailer remove attachment after send
body: <p>I am trying to remove the attachment files after sending an email with <strong>Symfony 2.1</strong> and <strong>Swiftmailer</strong> but if I delete the file before returning a response object (a redirect),  the email does not send.</p>
  
  <p>I suppose this is because symfony sends the email in the response, so when the email has send the attachment has been removed already.</p>
  
  <p>For example:</p>
  
  <pre><code>&lt;?php
  
  // DefaultCotroller.php
  
  $message = \Swift_Message::newInstance($subject)
      -&gt;setFrom('no-reply@dasi.es')
      -&gt;setTo($emails_to)
      -&gt;setBody($body, 'text/html')
      -&gt;attach(\Swift_Attachment::fromPath('backup.rar'));
  
  $this-&gt;get('mailer')-&gt;send();
  
  unlink('backup.rar');  // This remove the file but doesn't send the email!
  
  return $this-&gt;redirect($this-&gt;generateUrl('homepage'));
  </code></pre>
  
  <p>An option is to create a crontab to clean the files, but I prefer not using it.</p>
  
  <p>Thanks!</p>