title: Yii2 sending emails in the background
body: <p>I have a <code>RESTful API</code> which registers a user and later sends an email to that user for account activation.
  This works just fine but there is a great delay, since my code has to send the account activation email which sometimes takes time. How can I schedule jobs to run later or in the background for that task?</p>
  
  <p>This is what I am doing currently:</p>
  
  <pre><code>actionCreateUser(){
  
     //HERE REGISTRATION
  
    if($model-&gt;save()){  //successifull registration
  
      //send email here which takes time
      if($emailsent){
        return ["data"=&gt;true];
       }else{
          return ["data"=&gt;false];
       }
     }
  
  }
  </code></pre>
  
  <p>Then in the front-end I am checking the response of the <code>POST</code> request which is data(true or false).</p>
  
  <p>How can I send the email in the background?</p>