title: How can I sovle Internal Server Error for SendGrid Email Function
body: <p>I want to create <code>SendGrid</code> Email Function in <code>Windows Azure</code> with PHP.</p>
  
  <p>I referenced the code from Windows Azure as follow.</p>
  
  <pre><code>&lt;?php
   include_once "lib/swift_required.php";
   /*
    * Create the body of the message (a plain-text and an HTML version).
    * $text is your plain-text email
    * $html is your html version of the email
    * If the reciever is able to view html emails then only the html
    * email will be displayed
    */ 
   $text = "Hi!\nHow are you?\n";
   $html = &lt;&lt;&lt;EOM
         &lt;html&gt;
         &lt;head&gt;&lt;/head&gt;
         &lt;body&gt;
             &lt;p&gt;Hi!&lt;br&gt;
                 How are you?&lt;br&gt;
             &lt;/p&gt;
         &lt;/body&gt;
         &lt;/html&gt;
         EOM;
   // This is your From email address
   $from = array('someone@example.com' =&gt; 'Name To Appear');
   // Email recipients
   $to = array(
         'john@contoso.com'=&gt;'Destination 1 Name',
         'anna@contoso.com'=&gt;'Destination 2 Name'
   );
   // Email subject
   $subject = 'Example PHP Email';
  
   // Login credentials
   $username = 'yoursendgridusername';
   $password = 'yourpassword';
  
   // Setup Swift mailer parameters
   $transport = Swift_SmtpTransport::newInstance('smtp.sendgrid.net', 587);
   $transport-&gt;setUsername($username);
   $transport-&gt;setPassword($password);
   $swift = Swift_Mailer::newInstance($transport);
  
   // Create a message (subject)
   $message = new Swift_Message($subject);
  
   // attach the body of the email
   $message-&gt;setFrom($from);
   $message-&gt;setBody($html, 'text/html');
   $message-&gt;setTo($to);
   $message-&gt;addPart($text, 'text/plain');
  
   // send message 
   if ($recipients = $swift-&gt;send($message, $failures))
   {
       // This will let us know how many users received this message
       echo 'Message sent out to '.$recipients.' users';
   }
   // something went wrong =(
   else
   {
       echo "Something went wrong - ";
       print_r($failures);
   }
  ?&gt;
  </code></pre>
  
  <p>But this code cannot work properly and display Browser Setting Error and <code>HTTP エラー 500（Internal Server Error)</code>. </p>
  
  <p>How can I solve this error?</p>