0

I am new to PHP, I want to send emails to multiple recipients but from same mail client using mailto option in php for example I have an array containing email addresses. I tried this:

$recipients = array(
  "youremailaddress@yourdomain.com", 
  "youremailaddress2@yourdomain.com",

);
$email_to = implode(',', $recipients);  
$body = "Body";

But this will add all recipients on same email. I need to create separate Draft for all receivers and I want only one receiver in one draft. I can't use BCC. Can anyone help me out for creating mails using:

 "<a href='mailto:".$email_to."?body=".$body."' target='_top'> </a>"
Hunterr
  • 553
  • 1
  • 8
  • 28

1 Answers1

1

Well, supposing that what I commented was what you were looking for, I would do the following (you can edit it to just echo the whole thing):

$body = "Body";
$recipients = array(
    "youremailaddress@yourdomain.com", 
    "youremailaddress2@yourdomain.com",
);
foreach($recipients as $v){
    $a_tags .= '<a href="mailto:'.$v.'?body='.$body.'" target="_top"> </a>';
}

Note that I'm using .= so I can concatenate all the <a> tags, you can later output your $a_tags variable wherever you want.

Zeke
  • 1,281
  • 1
  • 18
  • 26
  • If you get that exception again (which I don't see why you would get it), let me know and update your question with the report you got so I can check it out. Maybe this isn't the right approach for your project, but I don't know since I don't even know about it. – Zeke Jan 20 '16 at 08:05
  • Thanks for the solution, with slight changes on your answer it worked out. :) – Hunterr Jan 21 '16 at 07:06
  • Alright, feel free to edit my answer to show the real solution! I'm glad I could help! – Zeke Jan 21 '16 at 12:20