Php SwiftMailer速度慢,内部服务器错误GoDaddy

Php SwiftMailer速度慢,内部服务器错误GoDaddy,php,swiftmailer,Php,Swiftmailer,我正在尝试使用SwiftMailer开发一个群发电子邮件系统(一次最多发送不超过200封电子邮件),但执行速度非常慢。它在发送纯文本电子邮件时有效,但带有附件的电子邮件需要一段时间 当我向163个用户发送一封包含1.5MB附件的电子邮件时,有时会出现500个内部服务器错误,但我会检查错误日志,他们不会说任何话(可能是因为我在GoDaddy上使用共享Linux主机)。错误出现前大约需要2分21秒,只有114个SMTP中继,而不是163个编辑:我已将此代码添加到脚本的顶部,但仍然存在相同的问题 se

我正在尝试使用SwiftMailer开发一个群发电子邮件系统(一次最多发送不超过200封电子邮件),但执行速度非常慢。它在发送纯文本电子邮件时有效,但带有附件的电子邮件需要一段时间

当我向163个用户发送一封包含1.5MB附件的电子邮件时,有时会出现500个内部服务器错误,但我会检查错误日志,他们不会说任何话(可能是因为我在GoDaddy上使用共享Linux主机)。错误出现前大约需要2分21秒,只有114个SMTP中继,而不是163个编辑:我已将此代码添加到脚本的顶部,但仍然存在相同的问题

set_time_limit(0);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '256M');
ini_set('mysql.connect_timeout', 500);
ini_set('default_socket_timeout', 500);
以下是出现的错误:

内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求

请通过以下地址与服务器管理员联系:webmaster@mitsapp.com通知他们此错误发生的时间,以及您在此错误之前执行的操作

有关此错误的详细信息,请参阅服务器错误日志

此外,尝试使用ErrorDocument处理请求时遇到500内部服务器错误

我已经在try/catch块中有了代码,但目前没有显示任何错误。我认为问题在于脚本中出现的查询量。如果是,我如何优化它们?如果没有,我如何解决这个问题?以下是从添加附件开始的代码:

//Add attachments
if(isset($_FILES['attachments'])) {
    $attCount = count($_FILES['attachments']['name']);
    $x = 0;
    while($x < $attCount) {
        if(!isset($_FILES['attachments']['name'])) {
            continue;
        }
        $message->attach(Swift_Attachment::fromPath("uploads/".$_FILES['attachments']['name'][$x]));
        $x++;
    }
}

//Sender Details
$message->setFrom('no-reply@mitsapp.com');
$message->setSender('no-reply@mitsapp.com');
try {$reply = Swift_Validate::email($_POST['reply']);} catch(Exception $e) {header("Location: ../communicate.php?error=2");}
$message->setReturnPath($_POST['reply']);
$message->setReplyTo($_POST['reply']);

//Send the message
require "connect.php";
$failedRecipients = array();
$numSent = 0;
$sendTo = $_POST['sendTo'];
$emails = array();
foreach ($sendTo as $ID) {
    $sql = "SELECT * FROM ".strtolower($_SESSION["mid"])."_current_roster WHERE ID=".$ID;
    $result = mysqli_query($conn, $sql) or die("Error sending email. ".mysqli_error($conn));
    if(mysqli_num_rows($result)  > 0) {
        while($row = mysqli_fetch_assoc($result)) {
            $emails[] = $row['email'];
        }
    }
}
foreach($emails as $address) {
    $message->setTo($address);
    $numSent += $mailer->send($message, $failedRecipients);
}
//添加附件
如果(isset($\u文件['attachments'])){
$attCount=count($_文件['attachments']['name']);
$x=0;
而($x<$attCount){
如果(!isset($_文件['attachments']['name'])){
继续;
}
$message->attach(Swift_Attachment::fromPath(“uploads/”$_FILES['attachments']['name'][$x]);
$x++;
}
}
//发件人详细信息
$message->setFrom('否-reply@mitsapp.com');
$message->setSender('否-reply@mitsapp.com');
尝试{$reply=Swift_Validate::email($_POST['reply']);}catch(异常$e){header(“位置:../communicate.php?error=2”);}
$message->setReturnPath($_POST['reply']);
$message->setReplyTo($_POST['reply']);
//发送消息
需要“connect.php”;
$failedRecipients=array();
$numSent=0;
$sendTo=$_POST['sendTo'];
$emails=array();
foreach($sendTo as$ID){
$sql=“SELECT*FROM”.strtolower($\u SESSION[“mid”])。“\u当前\u花名册,其中ID=”.$ID;
$result=mysqli_query($conn,$sql)或die(“发送电子邮件时出错”。.mysqli_Error($conn));
如果(mysqli_num_行($result)>0){
while($row=mysqli\u fetch\u assoc($result)){
$emails[]=$row['email'];
}
}
}
foreach($电子邮件地址){
$message->setTo($address);
$numSent+=$mailer->send($message,$failedRecipients);
}
之后还有更多代码可以正常工作,没有内部服务器错误,但在出现错误时不会运行