PHP使用PHPMailer发送附件 - 执行速度慢

时间:2014-08-12 21:38:59

标签: php phpmailer microtime

目前我正在尝试使用PHPMailer发送带文件附件的电子邮件。不幸的是,每个脚本执行大约需要60秒才能发送消息。这是我的代码:

 $time_start = microtime(true);
require_once('class.phpmailer.php');

$mail             = new PHPMailer(); // defaults to using php "mail()"


//$body             = file_get_contents('contents.html');
//$body             = eregi_replace("[\]",'',$body);

$mail->AddReplyTo("name@yourdomain.com","First Last");

$mail->SetFrom('name@yourdomain.com', 'First Last');

$mail->AddReplyTo("name@yourdomain.com","First Last");

$address = "xxx@gmail.com";
$mail->AddAddress($address, "John Doe");

$mail->Subject    = "PHPMailer Test Subject via Sendmail, basic";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML("html body");

$mail->AddAttachment("abc.txt");      // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}
$time_end = microtime(true);
$execution_time = ($time_end - $time_start);
echo 'Total Execution Time:'.$execution_time.' Sec';

执行时间并不是很大程度上取决于文件大小,但是60秒的脚本执行时间对我来说太过分了。我该如何解决这个问题?

0 个答案:

没有答案