Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/141651-slow-mail-function/
Share on other sites

It doesn't seem to matter whether I send it to one person, or three.

 

Here's what I have for the header:

    $to = "mfoster@xxxxxx.org";

    $from = "Conference Registration System";

    $subject = "Conference Request Update - Notification of approval";

 

    $headers  = "From: $from\r\n";

    $headers .= "Content-type: text/html\r\n";

 

 

It seems to follow the rules, but please point out problems if you see them

Link to comment
https://forums.phpfreaks.com/topic/141651-slow-mail-function/#findComment-741564
Share on other sites

Well, I looked up the reference that you cited and editted my code to the following:

 

$from = "Conference Registration System";

$headers  = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: html; charset=iso-8859-1' . "\r\n";

 

$headers  = "From:" . $from . "\r\n";

   

    // now lets send the email.

  mail($to, $subject, $message, $headers);

 

Unfortunately, it had no effect on the time it takes for the script to work.  However, now the email comes out with the source code for the html message rather than the display of the code!  Not good.

Link to comment
https://forums.phpfreaks.com/topic/141651-slow-mail-function/#findComment-741608
Share on other sites

The host maintains that all of their equipment are working properly and that it is a problem with php coding which they do not support.

 

I resubmitted the trouble ticket and replied that it certainly looks like it's a server problem and NOT a php problem.  So far no new replies.

Link to comment
https://forums.phpfreaks.com/topic/141651-slow-mail-function/#findComment-742796
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.