Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

$email->setCc(); send to multiple email, comma separated?


Go to End


2 Posts   3552 Views

Avatar
novaweb

Community Member, 116 Posts

13 August 2014 at 5:00pm

Edited: 13/08/2014 5:00pm

Hi Team,

End of day. Due to lovely security restrictions at my place of work, I am unable to test sendmail on my development machine.

Could someone please confirm or deny if $email->setCc will send to multiple email addresses, if separated by a comma?

SS/CWP 3.1.X

Thanks in advance, pat yourself on the back.

Josh (sucks)

Avatar
Mia

Community Member, 8 Posts

6 September 2014 at 1:31am

Hey!

Ohh so many things to say...

Firstly, the to is comma separated, i.e. 'mail@server.dom,mail2@server.dom,mail3@otherserver.dom'

It should be one string. You can also test easily not to send duplicates by doing:

$to = ''; //single quotes to prevent the parser from bugging
foreach ($receivers as $receiver){
    if (!stristr($to,$receiver->Email)) $to .= $receiver->Email;
}

//then pass $to in the email parameter

On another note. You do not need to send emails live to test them. There is a debugging tool built into Silverstripe for that purpose.

//create email here

//then do something like this
if (SiteConfig::current_site_config()->DebuggingMode)
    print_r($email->debug());
else
    $email->send();

Hope that helps!