title: How to send email as webscript in background in alfresco 4?
body: <p>I  have webscript written in Javascript for send emails. It works pretty well, but I would like to send those emails   in background, so that action can not slow further code execution. How can I do that?</p>
  
  <p>Thanks in advance!</p>
  
  <p>Best,
  D</p>
  
  <p>Addtional code:</p>
  
  <p>I created sendmail.lib.js which is included in needed js files with following signature:</p>
  
  <pre><code>function sendmail(to, subject, nodeRef, templatePath, templateArgs, textIfTemplateNotFound )
  </code></pre>
  
  <p>This function ends with the line:</p>
  
  <pre><code>mail.execute(search.findNode(nodeRef));
  </code></pre>
  
  <p>This is the way I need to send e-mails and on very specific events not related to "out-of-the-box" Alfresco events.</p>