Jump to content

Recommended Posts

  • Moderators
Posted

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!

  • 8 months later...
  • Administrators
Posted

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.

  • Administrators
Posted

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.

Posted

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 :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...