开发者

how to send many emails in one time by php

i want know how i can send one mail to 200 user and i want when the email sendt it appeare send to:user@mail.com from:my m开发者_开发技巧ail

because i think i see many email like that to:email1@exaple.com;email2@exaple.com;emial3@exaple.com; ithink this from bbc

i mean i want every user see sent to this email only


You can use the native mail() function, separate the addresses with a comma, and put them all in the blind carbon copy list with additional headers.

$to       = "jon@abc.com,sal@example.com";
$subject  = "Mini-mass Emailer";
$message  = "Hello World";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Your Name <me@mydomain.com>' . "\r\n";
$headers .= 'Bcc: {$to}' . "\r\n";

mail($to, $subject, $message, $headers);

Or you could iterate over the collection of email addresses and send each message individually:

$emails = array("foo@bar.com","fizz@buzz.com");
foreach ($emails as $email) {
  $to = $email;
  $subject = "My Subject";
  $message = "Hello World";

  mail($to, $subject, $message);
}


Send each mail separately to each user. You can write a helper utility function to do this iteratively.


if use mail function

use bcc in header like this :

$headers .= 'Bcc: 1@example.com,2@example.com.............' . "\r\n";

u can use a class like phpmailer and use AddBCC() function

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜