|
-
Sep 11th, 2006, 11:30 AM
#1
Thread Starter
Addicted Member
Question in sending emails
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:
PHP 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
-
Sep 11th, 2006, 11:58 AM
#2
<?="Moderator"?>
Re: Question in sending emails
have you tried using 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?
-
Sep 11th, 2006, 12:05 PM
#3
Re: Question in sending emails
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 11th, 2006, 12:30 PM
#4
Thread Starter
Addicted Member
Re: Question in sending emails
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
-
Sep 11th, 2006, 12:39 PM
#5
Re: Question in sending emails
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?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 11th, 2006, 12:46 PM
#6
Thread Starter
Addicted Member
Re: Question in sending emails
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?
-
Sep 11th, 2006, 01:33 PM
#7
Re: Question in sending emails
-
Sep 11th, 2006, 05:47 PM
#8
Thread Starter
Addicted Member
Re: Question in sending emails
What's set_time_limit() and what does it do?
Will it solve my problem?
-
Sep 12th, 2006, 12:55 AM
#9
Re: Question in sending emails
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.
-
Sep 12th, 2006, 04:59 AM
#10
Thread Starter
Addicted Member
Re: Question in sending emails
How can I use it with mail function?
-
Sep 12th, 2006, 09:49 AM
#11
<?="Moderator"?>
Re: Question in sending emails
look though the comments on the link to the PHP manual Penagate posted.
PHP Code:
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.
-
Sep 12th, 2006, 11:02 AM
#12
Thread Starter
Addicted Member
Re: Question in sending emails
It showed me "HTTP 500 Internal server error".
-
Sep 12th, 2006, 11:19 AM
#13
<?="Moderator"?>
Re: Question in sending emails
Do you use IE and have "Show HTTP Friendly Errors" turned off? Is it when you call set_time_limit?
-
Sep 12th, 2006, 11:45 AM
#14
Thread Starter
Addicted Member
Re: Question in sending emails
It always shows "HTTP 500 Internal server error" before and after I called set_time_limit().
-
Sep 14th, 2006, 07:04 AM
#15
Thread Starter
Addicted Member
Re: Question in sending emails
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|