Guestbook notify email - using multiple addresses?

Permalink
Hi, when someone posts a comment using the guestbook block we want the notifications to go to multiple email addresses. I've tried comma delimiting, and comma+space delimiting but the mails are never sent. Sending to a single email address works fine. Any advice on how to fix this?

 
Lemonbrain replied on at Permalink Reply
Lemonbrain
Unfortunatly it's not so easy possible. You need to customize the block for this functionality.

Actual it looks like this in the controller.php on line 169

if( $stringsHelper->email($this->notifyEmail) ){
   $c = Page::getCurrentPage(); 
   if(intval($uID)>0){
      Loader::model('userinfo');
      $ui = UserInfo::getByID($uID);
      $fromEmail=$ui->getUserEmail();
      $fromName=$ui->getUserName();
   }else{
      $fromEmail=$_POST['email'];
      $fromName=$_POST['name'];
   } 
   $mh = Loader::helper('mail');
   $mh->to( $this->notifyEmail ); 
   $mh->addParameter('guestbookURL', Loader::helper('navigation')->getLinkToCollection($c, true)); 
   $mh->addParameter('comment',  $_POST['commentText'] );


Solution:
first save the mailaddresses with a separator, for example ','. then split the address with this separator:
$mailaddresses = explode(",", $this->notifyEmail);


Now you can use the whole code from the beginning in a foreach and call it for every emailaddress
foreach($mailaddresses as $mailaddress){
  //Code from the beginning (use $mailaddress instead of $this->notifyEmail)
}


it would also be possible to use more then one
$mh->to( $this->notifyEmail );
for one mail object. But I think so it will be easier, then you need just a few adaptations.

I hope you understand what I mean, otherwise don't hesitate to ask further questions.
GrowingOld replied on at Permalink Reply
This is exactly what I am trying to do. I have tried using the code but I can't seem to get it working. I think I have the foreach loop in the wrong place. Where would that code go?
Thanks for your help

Update:
I had the end bracket in the wrong place. I now have it working.
mnakalay replied on at Permalink Reply
mnakalay
Hello,

Are you aware that, if you modified the block directly, you will lose your modifications next time you upgrade Concrete5?

The proper way of doing it is to override the block's controller by putting a copy in blocks\guestbook and modify that one.