Php 如何解决SendGrid电子邮件功能的内部服务器错误

Php 如何解决SendGrid电子邮件功能的内部服务器错误,php,html,azure,smtp,Php,Html,Azure,Smtp,我想用PHP在WindowsAzure中创建SendGrid电子邮件功能 我引用了WindowsAzure中的代码,如下所示 <?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 versi

我想用PHP在
WindowsAzure
中创建
SendGrid
电子邮件功能

我引用了WindowsAzure中的代码,如下所示

<?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 = <<<EOM
       <html>
       <head></head>
       <body>
           <p>Hi!<br>
               How are you?<br>
           </p>
       </body>
       </html>
       EOM;
 // This is your From email address
 $from = array('someone@example.com' => 'Name To Appear');
 // Email recipients
 $to = array(
       'john@contoso.com'=>'Destination 1 Name',
       'anna@contoso.com'=>'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->setUsername($username);
 $transport->setPassword($password);
 $swift = Swift_Mailer::newInstance($transport);

 // Create a message (subject)
 $message = new Swift_Message($subject);

 // attach the body of the email
 $message->setFrom($from);
 $message->setBody($html, 'text/html');
 $message->setTo($to);
 $message->addPart($text, 'text/plain');

 // send message 
 if ($recipients = $swift->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);
 }
?>

除了上面的代码外,我如何使用SendGrid电子邮件服务为我的网站创建电子邮件发送功能?你知道怎么做吗?现在,我知道了。错误原因是$html中的语法错误=