title: send email in background process in php
body: <p>I want to send a welcome email when a user registers in my app.
  When a user registers he gets redirected to his profile page.
  I tried sending email while user creation but the email() takes 7 seconds to send email, and the page waits till then and then redirects the user to profile after 7 sec.</p>
  
  <p>This is not desired. I want to redirect user as soon he registers, and send an email along the process. It takes 7 sec don't know why. i tried it online on godaddy and hostgator account as well as on my localhost.</p>
  
  <p>BTW: i am using PHPMailer to send email.</p>
  
  <p>How can can i make a standalone process which on invoke calls my sendMail.php with email $_POST[] parameters {to, subject, body}.</p>
  
  <p>i though ajax call will do the trick, but as soon as my page redirects from registration to profile, the email script stops.
  I tried this code:</p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
      $.post( "sendMail.php", { to: "$to", subject: "$subject", htmlBody: "$htmlBody", altBody: "$altBody" } );
  location.href=profile.html
  &lt;/script&gt;
  </code></pre>
  
  <p>Please help, i searched a lot but they work on shell which i am not, and other solutions were unix/linux based. i want to make it work on xampp as well as godaddy linux shared hosting, with NO ssh access.</p>