I am using PHP-Mailer. its working fine but its send email very slow. like some time its took one sec to send email.but mostly it took more then 2 min or more some time it took 30 min. is there is any alternative email sending method. or any way to send mail in 3 sec or 10 sec.
$mail->Timeout = 36000;
$mail->Subject = "Registration";
$mail->From = "info@educatorguru.com";
$mail->FromName = "Educatorguru.com";
$mail->AddReplyTo( "info@educatorguru.com" );
$mail->AddAddress( $email );
$mail->Body =$message2;
$mail->IsHTML(true);
$mail->Send();
The PHPMailer wiki has an article on maximising performance when sending in volume, but similar measures help single messages too.
With the code you posted, it means you're sending using PHP's mail()
function, which uses a sendmail binary to open a synchronous SMTP connection to localhost - you can help debug what's actually holding things up by adding this to your script:
$mail->isSMTP();
$mail->Host = 'localhost';
$mail->SMTPDebug = 2;
This will produce lots of debug output with timestamps, so you'll be able to see what part is slow.
The alternative is not to send interactively - store your messages in a 'to do' list/queue and get a cron job or other process to pick up messages and send them asynchronously - this will mean that your pages can return instantly without having to wait for the message to send.