Click to See Complete Forum and Search --> : Question in sending emails
onh1986
Sep 11th, 2006, 11:30 AM
Hello
I have a website and I have about 2000 emails in database and I want to send an email to them.
I use this code:
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: My Name <myemail@mywebsite>\r\n";
$headers .= "X-Priority: 1\r\n";
$result = mysql_query("select * from table");
while ($row = mysql_fetch_array($result)) {
mail ($row[Email],<title>,$message,$headers);
echo $row[Email] . "<br>";
}
When it's starting sending, after a minute it shows me "HTTP Page Error 500".
It sends about 200 emails then it stops and shows "HTTP Page Error 500".
What's the problem?
How can I solve it?
Thanks
john tindell
Sep 11th, 2006, 11:58 AM
have you tried using sleep() (http://uk2.php.net/sleep) to take the load of the server? Does it does it give you any other information about the error apart from 500 internal server error?
CornedBee
Sep 11th, 2006, 12:05 PM
I think the problem is the other way round: PHP has a limit on execution time. After 30 seconds, your script is forcibly stopped.
You can (if you have access to php.ini) increase the execution time. A better way would be to bulk-send the mails in a single call to mail(): a mail may have more than one destination. I'm not sure if and how mail() supports this, but the underlying protocol permits it.
onh1986
Sep 11th, 2006, 12:30 PM
Now I've tried to send an email to 500 person then it shows me:
Problem Report
Condition TCP error was detected while attempting to retrieve the URL: 'http://eenglish.onh1986.com/admin.php?show=members&page=5'.
--------------------------------------------------------------------------------
Problem Description: TCP/IP processing failure.
Try RELOADING the page.
This error message means that the target host did not properly respond to HTTP GET request after successfully establishing TCP connection. This may be due to problems like congestion on target host or transmission path.
If this problem persists for extended periods of time, contact your network support team. Please, first make sure that the target is really reachable and not, for example, out of service due to maintenance.
Current GMT Date/Time: Mon, 11 Sep 2006/20:29:00
And how can I increase the execution time?
Thanks
CornedBee
Sep 11th, 2006, 12:39 PM
As I said, in php.ini. I think the setting is called max_execution_time.
That's a very weird error message. What browser and server are you using?
onh1986
Sep 11th, 2006, 12:46 PM
My browser is IE 6.0.
What do you mean about the server which I'm using?
But this is the first time I see that page, usually I see "HTTP Error Page 500".
max_execution_time is set to "30" in default.
What should I do?
penagate
Sep 11th, 2006, 01:33 PM
Use set_time_limit() (php.net/set_time_limit).
onh1986
Sep 11th, 2006, 05:47 PM
What's set_time_limit() and what does it do?
Will it solve my problem?
penagate
Sep 12th, 2006, 12:55 AM
It's a link. You're supposed to click on it.
Even if I hadn't provided a link, you could have copied and pasted it into Google search and found it instantly.
onh1986
Sep 12th, 2006, 04:59 AM
How can I use it with mail function?
john tindell
Sep 12th, 2006, 09:49 AM
look though the comments on the link to the PHP manual Penagate posted.
set_time_limit(0); // run script forever
The PHP manual is the best reference for when you need to learn how to use, or what function to use in PHP. There are also loads of comments about how to use them with suggestions for other methods which you may or may not know about.
onh1986
Sep 12th, 2006, 11:02 AM
It showed me "HTTP 500 Internal server error".
john tindell
Sep 12th, 2006, 11:19 AM
Do you use IE and have "Show HTTP Friendly Errors" turned off? Is it when you call set_time_limit?
onh1986
Sep 12th, 2006, 11:45 AM
It always shows "HTTP 500 Internal server error" before and after I called set_time_limit().
onh1986
Sep 14th, 2006, 07:04 AM
Please I need help.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.