Mostafa Elkady
Mostafa Elkady

Reputation: 5781

which of this method is recomended - mail function

hay now i want to send mail to 200 users first way $users = 'user1@,user2@,user3,etc';

foreach(explod(',',$users as $mail){
mail($mail,'','','');
}

or

mail(mail one,mail 2,mail3,mail4,etc)

i know the code is fully error

but i want the meaning

which is the best mail with multi by spreate by , or looping the mail function with the one mail every time

Upvotes: 0

Views: 94

Answers (1)

Dereleased
Dereleased

Reputation: 10087

Ideally, you should use an external piece of mailing software so you can send an e-mail to a list and it will handle individual recipients; this way, you can avoid looping mail calls (and queued sendmail requests) while not disclosing your mailing list.

Of the options you presented, it is best to send your email using a loop with individual calls to the mail function so as not to disclose your recipients.

Finally, maybe try something like this:

$recipients = array('[email protected]','[email protected]',); // mail list
$bcc = join(',', $recipients);
mail(
    '"Undisclosed Recipients" <[email protected]>', 
    $subject, 
    $message, 
    "BCC: {$bcc}"
);

However, if you are using this, make sure whatever sendmail client you are using strips the BCC header before sending.

Upvotes: 2

Related Questions