I have a whole bunch of php scripts that utilize the mail() function. They have worked fine previously, but now, although they work, are very slow (20-30 seconds). I have written a couple of testing programs to make sure that the slow completion was due to the mail() function and have shown it is definitely related to it. In one program, I send the mail and in the other program I put comment code (//) in front of the mail statement so that everything else in the program is identical. The program with the active mail runs 20-30 seconds, while the inactivated mail program runs in less than 2 or 3 seconds.
I have not changed the code in the scripts, but the hosting company did move to a new server. The technician for the hosting site tells me that it is NOT a server problem, but a php coding problem. I honestly don't see how that could be true, but an open to any suggestions that anyone else has. Here is the code (with the mail function disabled) that seems to be the problem:
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
// now lets send the email.
//mail($to, $subject, $message, $headers);
I would be most appreciative of any suggestions.