Sending bulk email with comma separated |
Hi;
I send comma separated (or array) as $recepients. Emails get sent as bulk and everyone gets their copy. But everyone sees the receives as benscopy@***.com. They don't see it as their own email. How can I do it so they see it as their own email it's kinda confusing. Thanks PHP Code: public function send_email($recepients, $template)
That's because you're sending it TO "[email protected]", and BCCing everyone else. If you want it to go TO them, then send it TO them and don't BCC them. So you'd have to loop through them all and send an individual email. You'll be sending a lot more mail, but it will do what you want. This is just standard email stuff and doesn't really have to do with the CI email library. The same would happen if you did the same thing in your regular email client.
Also, where is $data coming from here? Seems you should be getting an error unless you didn't post your complete for that method.
PHP Code: $message = $this->load->view('email_template',$data,TRUE);
(03-31-2015, 08:02 AM)CroNiX Wrote: That's because you're sending it TO "[email protected]", and BCCing everyone else. If you want it to go TO them, then send it TO them and don't BCC them. So you'd have to loop through them all and send an individual email. You'll be sending a lot more mail, but it will do what you want.Any potential problems? I thought it might jam the server etc? About the code: Yes I didn't post all code I thought no one's gonna read it Here I paste it. Basically I mean scheduled emails. I know MailChimp etc etc are better but I suck at API's too and I don't have time to learn api at this moment. I was wondering if I missed anything and there are any obvious flaws in this script. It works fine! I don't expect to send more than 500 at a time. I only send to those who joined within past week. So I don't really worry about that loop. PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
In your send_email(), just loop through recipients and set the TO as their individual address and don't use BCC. That will make the email behave as you outlined in your first post by sending directly TO them. If you're worried about "jamming" the email server, you could always put a small delay in the loop, but most email servers should handle it with no problems.
(03-31-2015, 03:45 PM)CroNiX Wrote: In your send_email(), just loop through recipients and set the TO as their individual address and don't use BCC. That will make the email behave as you outlined in your first post by sending directly TO them. If you're worried about "jamming" the email server, you could always put a small delay in the loop, but most email servers should handle it with no problems.So are you saying there won't be any potential errors based on my requirements? Thanks
It should, but I don't know your server setup. How often are you doing this? You say there shouldn't be more than like 500 at a time, but is that every day, once a week, etc? You can always turn it into a cron job and run it every few hours or once a day so there aren't so many being sent at once if your worried about that, but 500 emails being sent in a loop shouldn't be a problem, but again that depends on your server resources, etc.
Check your provider's terms to determine how many emails they permit you to send (usually they will have a maximum number per hour). If the number of recipients is lower than the maximum, you should be fine, as long as you're not sending emails to these recipients frequently. Otherwise, you'll probably want to build a queue and process them on a schedule to make sure you don't get your site (or its access to send email) shut down.
|
Welcome Guest, Not a member yet? Register Sign In |