/    Sign up×
Community /Pin to ProfileBookmark

sending emails to many or inserting into db HELP

I have over 200 emails that I want to send a notice to. I have them listed separated by commas and I want to know how I can get them into the database in one code instead of adding them individually which will take forever. If I get them in the database I will know how to send them separatly with a while statement. Well I know I can I’m still unsure how so help on that will be good too. If theres a way I can send the emails without putting them in the db separatly then thats what im looking for. Thanks for any help at all!

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@adeang_1Mar 22.2008 — well I am not sure if this works, but Ill give you my idea

Ill try to make it later

but basically create and array

[CODE]$emails = array("[email protected]", "[email protected]", "[email protected]", "[email protected]");[/CODE]

do that but put all 200 in there, then



next

[CODE]for($i=0;$i<count($emails);$i++)
{
//connect to your db you know how to do that....
$insertinto[$emails[$i]];

//put code that inserts into db and table and use the varible $insertinto[$emails[$i]];

//as the email of the person to send too


}[/CODE]


should, i think, work but not sure havent ever tried that yet
Copy linkTweet thisAlerts:
@adeang_1Mar 22.2008 — make sure you close your database at end, you may not want to put the db connection inside for loop may want to put on outside so only connect once and then put the close connection on outsite of loop
Copy linkTweet thisAlerts:
@holidayMar 22.2008 — sort and sweet, edit as needed...

[code=php]<?php
//list of email addersses
$emails = '[email protected], [email protected],[email protected]';

//set email parameters
$subject = "The email subject";
$message = "The email body";

//remove spaces (if any exist)
$emails = str_replace(" ", "", $emails);

//put email addresses in an array
$email_array = explode(",", $emails);

//send emails
foreach($email_array as $email) {
mail($email, $subject, $message);
}
?>[/code]
Copy linkTweet thisAlerts:
@jwk811authorMar 22.2008 — thank you guys so much!
Copy linkTweet thisAlerts:
@knowjMar 22.2008 — I personally would look at another solution for sending to 200+ emails. If you read the mail function documentation on the php website it has a note that states this function is not for large volumes of emails

http://uk3.php.net/function.mail

Note: It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.

For the sending of large amounts of email, see the &#187; PEAR::Mail, and &#187; PEAR::Mail_Queue packages.

http://pear.php.net/package/Mail

http://pear.php.net/package/Mail_Queue
Copy linkTweet thisAlerts:
@hastxMar 24.2008 — For larger amounts of mail, i would pass each emails info into a function which composes the message and calls the mail function. This allows you to set timers and also error check each message and log it. This process takes some processing power, but might work better with the built in mail function. There used to be some free scripts around that used this idea. I remember one that you could set timers between each message and would send a report at the end of the job, i'll see if I can find it.
×

Success!

Help @jwk811 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...