payalbhatt — 2014-02-19T07:29:43-05:00 — #1
I am trying to send an email to multiple address with php script. I can send an email to multiple addresses. But what I dont want is no recipient can see other recipient's address.
For example I would like to send an email to 2 users (abc.gmail.com & firstname.lastname@example.org) now when i send an email to both these addresses, I dont want any of them to know that I have send the same email to other address too..
I dont want any BCC or CC. Kindly Please Help Me Out Anyone:rolleyes::rolleyes:
vectorialpx — 2014-02-19T09:36:56-05:00 — #2
Just send them individually, with a foreach loop.
Your problem needs BCC.
Without this header, you cannot "hide" some of the recipients just like that.
payalbhatt — 2014-02-19T10:58:19-05:00 — #3
Thanks For your Reply, Sorry But I am kind of new to PHP and would like to know how to add BCC in header, as I have tried few different ways, its not working. Thanks
qmonkey — 2014-02-19T15:40:46-05:00 — #4
If you use BCC you will still need a TO address which everyone will see. You could have the TO be the same as the FROM but to some people that is suspicious. How to do this depends on what you're using to send them. If you're just using PHP's built in mail() function, look at the additional_headers parameter. http://php.net/mail
If you don't want that you will just have to loop through and send each one a separate email.
felgall — 2014-02-19T15:50:54-05:00 — #5
Once the email is submitted to be sent it gets sent as an individual email to each recipient regardless. Setting it up with toa loop over all the email addresses with the loop changing theTo address and sending the email to that recipient results in exactly the same number of emails being sent as if you put one of the recipients in the To address and the rest in BCC. If you put all of them in BCC and use the from address or a dummy address as the To address you end up sending one more email than if you use a loop with the To address.
ralphm — 2014-02-19T16:02:48-05:00 — #6
It's less efficient (codewise, at least) but you can use mail() multiple times to send the email to different people. E.g.
mail ($email1, $subject, $body, $header);
mail ($email2, $subject, $body, $header);
mail ($email3, $subject, $body, $header);
vectorialpx — 2014-02-20T03:47:18-05:00 — #7
Ok, so. There are few things to understand:
1. When you add BCC with lots of emails, the email server will consider that you sent one (and only one) email. Why do you care about this?
2. Some hosts will not allow sending more than [x] emails per hour, where [x] may be 200 or a bit more (again, some hosts! ask at support about yours). If you need to send a newsletter, sending (example) 2000+ emails at once may get your account blocked. So, the BCC can help you a lot because you can split the number of emails to send into chunks and deliver all at once, without exceeding the limit.
3. To send emails with BBC you will have [TO]:email@example.com - [BCC]:firstname.lastname@example.org,email@example.com. So, do not have [TO]:george and [BCC]:mike,jhon because mike and jhon will see the email of george.
4. The best way of sending emails is to add all with [TO] and send multiple emails. If you do not exceed any limitation (as I said, talk with your hosting support) this is the best way - (as ralph.m said and also QMonkey - it's the same thing, different approaches).
Some code, from the manual with some adjustments
$to = 'firstname.lastname@example.org';
// also define your $subject and $message
// how to send an email with BCC
$headers = 'MIME-Version: 1.0' . "\\r\
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\\r\
// this email may not exist
$headers .= 'To: Website <email@example.com>' . "\\r\
// this is a good email, that must exist (some user may send a reply)
$headers .= 'From: Website <goodExistingEmail@website.com>' . "\\r\
// mails to be delivered to
$headers .= 'Bcc: firstname.lastname@example.org,email@example.com,firstname.lastname@example.org' . "\\r\
// Mail it
mail($to, $subject, $message, $headers);
payalbhatt — 2014-02-20T06:02:58-05:00 — #8
Who have helped me lot, Thank you so much for your time and Concern, my problem is solved with using logic .. i did was made 2 different "TO" variables and typed mail() twice giving both individual variables.
$success = mail($to,$emailSubject,$body,$headers);
$success = mail($to1,$emailSubject,$body,$headers);
knojiyak — 2014-02-21T11:15:37-05:00 — #9
Use this code..
$to = "email@example.com,firstname.lastname@example.org";
$headers1 = "MIME-Version: 1.0" . "\\r\
$headers1 .= "Content-type:text/html;charset=iso-8859-1" . "\\r\
$headers1 .= "From: email@example.com\\r\
$content1.="<table width='100%' border='1'>
<tr><td>Your Name </td> <td>kewal knojiya </td></tr>
felgall — 2014-02-21T15:52:23-05:00 — #10
No it doesn't - each gets sent as a separate email. If you have lots of BCC you are sending lots of individual emails. Hosts are not going to be stupid enough to allow you to send out millions of spam emails just because you BCC the recipients. Each and every email address specified in TO, CC and BCC counts as an email when determining how many emails you are sending.
Each BCC counts as one email so it doesn't help at all. What you have to do is to use a CRON job to send them a few at a time - so with a 200 email per hour limit and 2000 emails to send you spread them over say 12 hours.
This results in sending one more email when you use BCC than when you send them all separately if you use a TO address that is a dummy in order to not expose anyone's email address. So if you do have a limit then you can save one email per send by sending separately and not using BCC.
Definitely since it involves sending one less email and so helps to keep you under any limits
vectorialpx — 2014-02-23T14:00:03-05:00 — #11
It is true, I did a mistake.
About the counting, it depends on the server configuration.
That extra email is not the reason of "why is better to send individual emails".
And you know that. Anyway, you made your point