Moderators Kyle Posted August 12, 2011 Moderators Report Share Posted August 12, 2011 Hey guys, I been trying to figure out how I can make it work when a new pilot joins, I want the email to be sent out to three different people and I tried many methods like... $email = 'ceo@va.com, coo@va.com'; But It didn't work. Can anyone guide me in of what I am doing wrong? Thanks! Quote Link to comment Share on other sites More sharing options...
mattia Posted May 11, 2012 Report Share Posted May 11, 2012 i have the same problem Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted May 11, 2012 Administrators Report Share Posted May 11, 2012 I applied some changes to the util.class.php file to achive this. In /core/classes/util.class.php line 293 should be; $mail->AddAddress($email); change this line to; if(is_array($email)) { foreach($email as $address) { $mail->AddAddress($address); } } else { $mail->AddAddress($email); } which will allow you to supply an array of emails to the function. To send an email to a singular address as normal you can continue to use something like; $email = 'email1@gmail.com'; $message = 'Your Message'; $subject = 'Email Subject'; Util::SendEmail($email, $subject, $message); but now you can also supply an array of addresses for the email to be sent to like this $email = array('email1@gmail.com', 'email2@yahoo.com', 'email3@msn.com'); $message = 'Your Message'; $subject = 'Email Subject'; Util::SendEmail($email, $subject, $message); Just remember that the changes to the util class will be overwritten in an update. Quote Link to comment Share on other sites More sharing options...
Tom Posted May 11, 2012 Report Share Posted May 11, 2012 Edit: Nevermind Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted May 11, 2012 Administrators Report Share Posted May 11, 2012 Default mail() would support that, so I assume the function to send mail is changing it somehow. You could loop through an array of emails? $emails = ['me@me.com', 'you@me.com']; foreach($emails as $email){ // Do the sending part } Yes, that is another way to accomplish the function but that would bypass the use of the phpvms mail function which is tied to many other things in the system which is what I thought he was trying to achive. Guess I mis-understood. Quote Link to comment Share on other sites More sharing options...
Tom Posted May 11, 2012 Report Share Posted May 11, 2012 Yes, that is another way to accomplish the function but that would bypass the use of the phpvms mail function which is tied to many other things in the system which is what I thought he was trying to achive. Guess I mis-understood. Well, I assume the phpVMS method could still be used? I just left "// Do the sending part" to let people put anything... I couldn't remember the util function off the top of my head Here is my revised version: $emails = array('email1@gmail.com', 'email2@yahoo.com', 'email3@msn.com'); $message = 'Your Message'; $subject = 'Email Subject'; foreach($emails as $email){ Util::SendEmail($email, $subject, $message); } (Requires no modification of the core function) Though simpilot, you should add that as a pull req if you haven't already... no doubt useful for future versions Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.