title: Mail not sending in laravel 5 from an ajax post request
body: <p>I am working on forgot password functionality in my laravel 5.0 application. I am asking user to enter registered email and submit(post method) this form works on jquery ajax post request. After getting email from request i am checking it in db whether it exist or not. if exist i am updating new password, if not sending an error message upto this every this is fine. Now i am trying to send email with new password to the user, it is not working. Password is updating but email not sending.Find my controller code below<br/></p>
  
  <pre><code>public function forgot_pass(Request $request){
  
          $email = $request-&gt;input('femail');
          $data = ['email' =&gt; $email];
  
          $user = Myuser::where($data)-&gt;count();
  
          if($user == 0){
              return response()-&gt;json(['status' =&gt; 'Invalid']);
          }
          else{
  
              $user_details = Myuser::where($data)-&gt;get()-&gt;first();
  
              $new_pass = $this-&gt;generateRandomString();
  
              $md5_pass = md5("EEE".$new_pass);
  
              $status = Myuser::where('email', $email)
                  -&gt;update(['pass' =&gt; $md5_pass]);
  
                  if($status){
  
                      $mail_data = ['name' =&gt; $user_details-&gt;name, 'new_pass' =&gt; $new_pass];
  
                      Mail::send('emails.newpassword', $mail_data, function($message)
                      {
                          $message-&gt;from('us@example.com', 'Laravel');
  
                          $message-&gt;to($email);
  
                      });
  
                      return response()-&gt;json(['status' =&gt; 'Invalid']);
                  }
  
          }
  
      }
  </code></pre>
  
  <p>Actually mail is working if i used <code>$message-&gt;to('sometest@testmail.com');</code> instead of <code>$message-&gt;to($email);</code>. Below is the error i am getting.<br/>
  <a href="https://i.stack.imgur.com/0v2uI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0v2uI.jpg" alt="enter image description here"></a></p>
  
  <p>Feeling strange why <code>$email</code> causing error.</p>