title: Laravel 5 - Swift_TransportException: Expected response code 250 but got code "501", with message "501 5.5.4 Invalid domain name
body: <p>I was trying to use Laravel Mail service to send an email from my WAMP localhost. And I got the following error:</p>
  
  <blockquote>
    <p>Swift_TransportException in AbstractSmtpTransport.php line 383:
    Expected response code 250 but got code "501", with message "501 5.5.4
    Invalid domain name "</p>
  </blockquote>
  
  <p>The code to send the email is as follows:</p>
  
  <pre><code>public function sendTo($user, $subject, $view, $data = [])
  {
      \Mail::queue($view, $data, function ($message) use ($user, $subject) {
          $message-&gt;from(\Config::get('config.admin_email'), \Config::get('config.admin_name'));
          $message-&gt;to($user-&gt;email, $user-&gt;full_name)-&gt;subject($subject);
      });
  }
  </code></pre>
  
  <p>In .env, the setting is:</p>
  
  <pre><code>MAIL_DRIVER=smtp
  MAIL_HOST=mail.server.com
  MAIL_PORT=587
  MAIL_USERNAME=username
  MAIL_PASSWORD=password
  MAIL_ENCRYPTION=tls
  </code></pre>
  
  <p>I have tried to change <code>tls</code> to <code>ssl</code>, port number to 465, or 25. None of these worked.</p>
  
  <p>The mail server I am using is Microsoft Exchange server. </p>