currently I'm trying to send emails with file attachements using PHPMailer. Unfortunatelly, each script execution takes approximatelly 60 seconds to send a message. here is my code:
$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';
The time of execution is not very depending on file size, but 60 s of script execution time is a bit too much for me. How can I fix this?