简体   繁体   中英

php mail() function taking too much time to execute on centos6 server

I have written a small code to check the speed of my server. BUt it takes almost 60 seconds to finish execution.

<?php


     $start=time();

     $to = "test@gmail.com";

     $subject = "This is subject";

     $message = "<b>This is HTML message.</b>";
     $message .= "<h1>This is headline.</h1>";

     $header = "From:test@mydomain.com \r\n";
     $header .= "MIME-Version: 1.0\r\n";
     $header .= "Content-type: text/html\r\n";

     $retval = mail ($to,$subject,$message,$header);

     if( $retval == true ) {
        echo "Message sent successfully...";
     }else {
        echo "Message could not be sent...";
     }

     $after=time();
     $total=$after-$start;
     echo "</br>";
     echo "Total execution time : ".$total." seconds";
?>

What maybe the reason? and how can I improve the execution time? I already increased the memory limit in php.ini file.

It was an issue with sendmail mailserver. Installing postfix mailserver solved the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM