Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem: Simple mail() takes too long... need a suggestion

Status
Not open for further replies.

bnownlater

Programmer
Jan 16, 2002
8
US
I have a simple form with 15 variables that I mail to one person. The process is taking 30 + seconds to complete (which seems to be high)? Is there a better way to handle this? I am using 4.2.1 with Win NT. Here is my code:

// Set the script's max execution time to 300 seconds
set_time_limit(300);

$to = "myemail@mydomain.com"; //The e-mail address to be sent to
$subject = "Submission"; //The subject line of the e-mail
$mailheaders = &quot;From: &quot;.trim($reviewer).&quot;<&quot;.trim($rev_email).&quot;>\n&quot;; //The users name will appear here
$mailheaders .= &quot;X-Mailer: PHP\n&quot;; //mailer
$mailheaders .= &quot;X-Priority: 1\n&quot;; //1 UrgentMessage, 3 Normal
$mailheaders .= &quot;MIME-Version: 1.0\nContent-Type: text/html; charset=iso-8859-1\nTransport-Encoding: 8bit\n&quot;;//Converts text into html for the e-mail message
//$mailheaders .= &quot;Reply-To: myemail@domain.com\n\n&quot;; //a please reply message will display with e-mail address

$msg = &quot;
<style>}
TD { /* set default for text in a table */
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12pt;
vertical-align: top;
}
</style>
<table>
<tr><td>
<table border=1 cellspacing=1 cellpadding=3 >
<tr><td colspan=2 align=center bgcolor='2b4e8e'><font color='ffffff'><b>Your Information</b></font></td></tr>
<tr><td><br><b>Name:</b></td><td><br> $reviewer</td></tr>
<tr><td><b>Company:</b></td><td> $rev_co</td></tr>
<tr><td><b>E-mail:</b></td><td> $rev_email</td></tr>
<tr><td><b>Phone:</b></td><td> $rev_phone</td></tr>
<tr><td colspan=2 align=center bgcolor='2b4e8e'><font color='ffffff'><b>Facility Contact Information</b></font></td></tr>
<tr><td><br><b>Facility Name:</b></td><td><br> $co_name</td></tr>
<tr><td><b>City:</b></td><td> $co_city</td></tr>
<tr><td><b>State:</b></td><td> $co_state</td></tr>
<tr><td><b>Contact Name(s):</b></td><td> $cont_name</td></tr>
<tr><td><b>Contact E-mail(s):</b></td><td> $cont_email</td></tr>
<tr><td><b>Contact Phone Number(s):</b></td><td> $cont_phone</td></tr>
<tr><td><b>Contact Fax Number(s):</b></td><td> $cont_fax</td></tr>
<tr><td><b>Federal ID Number:</b></td><td> $fed_id</td></tr>
<tr><td><b>Web Site:</b></td><td> $web</td></tr>
<tr><td><b>Facility Type:</b></td><td> $fac_type</td></tr>
<tr><td><b>Recommendation:</b></td><td> &quot;;
If ($rec==&quot;3&quot;){
$msg = $msg.&quot;Highly Recommended</td></tr>&quot;;
}elseif ($rec==&quot;2&quot;){
$msg = $msg.&quot;Recommended</td></tr>&quot;;
}elseif ($rec==&quot;1&quot;){
$msg = $msg.&quot;Not Recommended</td></tr>&quot;;
}
$msg=$msg.&quot;

<tr><td><b>Comment:</b></td><td> $comm_comment</td></tr>
</table>
</td></tr>
</table>&quot;;
mail($to, $subject, $msg, $mailheaders); //mail function to e-mail the form
 
Insufficient data for a meaninful answer.

Where is your mail server in relation to your web server?

What software is your mail server running and running on?

If you telnet to port 25 on that mail server from your web server, how long does it take for the mail server to respond? ______________________________________________________________________
TANSTAAFL!
 
Hi,

Not sure if this helps or not but on my test server at home if I disconnect it from the net it takes a _long_ time to do a mail() and httpd stalls whilst it is working.

I assumed this was to do with DNS lookups or something but this is a wild accusation as I do not know what the mail function actually does.

[smurf]
01101000011000010110010001110011
 
Have you set the SMTP in the php.ini? You have to configure it putting there the SMTP you usualy use.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Thanks to all. I know that our mail server is loacted in our DMZ. Not real sure what software it is running? Do not know how to telnet to port 25? My PHP.ini file is correct with the server name. Someone suggested to put the IP address instead of the server name, due to DNS resolve problems. I am going to try this first and will let you know. Thanks again for the responses. Learning everyday!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top