Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Hostgator共享服务器在提交Pear邮件脚本后挂起_Php_Html_Pear - Fatal编程技术网

Php Hostgator共享服务器在提交Pear邮件脚本后挂起

Php Hostgator共享服务器在提交Pear邮件脚本后挂起,php,html,pear,Php,Html,Pear,显然,我的hostgator共享托管服务器在下面的脚本运行后挂起 虽然脚本返回一条成功发送的消息,但它不会被发送。SMTP设置在我整个网站中使用时已验证是否正常工作。我在这个文档中找不到更多的错误,我的主机似乎也不知道它为什么挂起或者为什么不发送 我是不是忽略了什么?有什么想法吗 <?php require_once "Mail.php"; include('../../Redirect_modules.php'); function sendmail($type,$subject,$b

显然,我的hostgator共享托管服务器在下面的脚本运行后挂起

虽然脚本返回一条成功发送的消息,但它不会被发送。SMTP设置在我整个网站中使用时已验证是否正常工作。我在这个文档中找不到更多的错误,我的主机似乎也不知道它为什么挂起或者为什么不发送

我是不是忽略了什么?有什么想法吗

<?php
require_once "Mail.php";
include('../../Redirect_modules.php');

function sendmail($type,$subject,$body)
{
  if($type==1) $WET = DBGet(DBQuery("SELECT * FROM staff"));
  else $WET = DBGet(DBQuery("SELECT * FROM staff where profile='$type'"));  

  $from = "";

  $host = "";
  $username = "";
  $password = "";

  $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);

  $smtp = Mail::factory('smtp',
    array ('host' => $host,
      'auth' => true,
      'username' => $username,
      'password' => $password));

  $mail = $smtp->send($to, $headers, $msg);

  foreach($WET as $e)
  {
    $to = $e['EMAIL'];
    $mail = $smtp->send($to, $headers, $body);

    if (PEAR::isError($mail)) {
      echo("<p>" . $mail->getMessage() . "</p>");
    } else {
      //echo("<p>Message successfully sent!!</p>");
    }
  }
}

function sendsinglemail($to,$subject,$body)
{
  $from = "Your Name";

  $host = "";
  $username = "";
  $password = "";

  $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);

  $smtp = Mail::factory('smtp',
    array ('host' => $host,
      'auth' => true,
      'username' => $username,
      'password' => $password));

  $mail = $smtp->send($to, $headers, $body);

  if (PEAR::isError($mail)) {
    echo("<p>" . $mail->getMessage() . "</p>");
  } 
  else {
    echo("<p>Message successfully sent!!</p>");
  }

}

if($_REQUEST['modfunc']=='send')
{
  if($_POST['roption2']=='0')
  {
    sendmail($_POST['roption1'],$_POST['subject'],$_POST['message']);       
  }
  else
  {
    sendsinglemail($_POST['roption2'],$_POST['subject'],$_POST['message']); 
  }
}

$RET = DBGet(DBQuery("SELECT * FROM staff")); 
?>

<h2> Communicate with Teachers or Parents individually or by group via Email </h2>
<form action="<?php echo "Modules.php?modname=$_REQUEST[modname]&modfunc=send" ?>"     method=POST>
 <table width="500">
 <tr><td> To:</td> <td><select name="roption1" id="groupselect">
 <option value="1">All Administrators, Teachers and Parents</option> 
 <option value="admin">All Administrators</option>
 <option value="teacher">All Teachers </option>
 <option value="parent">All Parents</option>
 </select> 
  or 
 <select  name="roption2" id="individual">
    <option value="0" SELECTED>Select User</option> 
    <?php foreach($RET as $userdata){ ?>
      <option value="<?php echo $userdata['EMAIL']; ?>"><?php echo    $userdata['FIRST_NAME']." ".$userdata['LAST_NAME']; ?></option>
    <?php } ?>
 </select> 
 </td>
 </tr>
 <tr><td> Subject:</td> <td> <input type="text" name="subject" /> </td></tr>
 <tr> <td> </td> <td>Message: <br/> <textarea cols="60" rows="10" name="message">    </textarea> </td></tr>
  <tr> <td><input type="submit" value="send" name="submit" />
 </table>
</form>
<?php
?>

我犯了一个明显的错误,FROM字段没有正确填写,因此导致反弹后挂起

邮件::工厂('smtp',数组(
)中添加
'debug'=>true
,以获取调试信息并进行检查。