Link to home
Start Free TrialLog in
Avatar of phillystyle123
phillystyle123Flag for United States of America

asked on

send message to 2 email accounts

I need to use this to send emails to 2 email addresses:
            $this->sendMessage("me@mysite.com", $mSubject, $message);
            $this->sendMessage($to, "Thank you", $message_customer);

Something like this:
$this->sendMessage("me@mysite.com, them@theirsite.com", $mSubject, $message);
            $this->sendMessage($to, "Thank you", $message_customer);
Avatar of Tyler Laczko
Tyler Laczko
Flag of Canada image

you can seperate multiple email addresses by doing:

$to = "email@domain.com; email2@domain2.com";
basically in the to field concatenate email addresses using the ;
You can also inline the $to variable along with any other emails which will be expanded in your string:
 
$this->sendMessage("me@mysite.com;them@theirsite.com", $mSubject, $message);
$this->sendMessage("$to;something@email.com", "Thank you", $message_customer);

Open in new window


NOTE: As shown above, you should use a semi-colon to separate email addresses in case you don't see that.
Uhh, it kind of looks like you want to send the messages to three accounts?  me, them, and whatever address is in $to?
Avatar of phillystyle123

ASKER

still not getting this - I've tried
$this->sendMessage("me@mysite.com;them@theirsite.com", $mSubject, $message);

neither email gets sent.  i'm looking for a cc - the $to variable is sending a confirmation email

function notify_singup($to, $message, $message_customer)
      {
            $mSubject ="New Good Samaritan Hosiptal donation has been received";            
                                    
            
            
            $this->sendMessage("elkinhimer@sbcglobal.net", $mSubject, $message);
            $this->sendMessage($to, "Thank you for your donation to Good Samaritan Hospital", $message_customer);
      }
ASKER CERTIFIED SOLUTION
Avatar of phillystyle123
phillystyle123
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question should be deleted.  The answer exists within the original question, and since the source for the function in question ("sendMessage()") is not provided, its functionality is questionable.  The question is misleading and not helpful at all.
I disagree -the answer does not exist in the original question - please advise

Here's the entire function:

function notify_singup($to, $message, $message_customer)
      {
            $mSubject ="New Good Samaritan Hosiptal donation has been received";            
                                    
            
            
            $this->sendMessage("email1@mysite.com", $mSubject, $message);
            $this->sendMessage("email2@mysite.com", $mSubject, $message);
            $this->sendMessage($to, "Thank you for your donation", $message_customer);
The function/method for which we have no reference or source is "$this->sendMessage()"; you gave the source for the method "notify_singup()".  

From the original question:
$this->sendMessage("me@mysite.com, them@theirsite.com", $mSubject, $message);
            $this->sendMessage($to, "Thank you", $message_customer);

Open in new window

Your solution:
$this->sendMessage("email1@mysite.com", $mSubject, $message);
            $this->sendMessage("email2@mysite.com", $mSubject, $message);

Open in new window


The difference is that in your proposed solution, the first call to sendMessage() passed two email addresses separated by a comma.  The second call simply changed a variable ("$to") to arbitrary text ("email1@mysite.com").

As pointed out by several experts, your original question seemed to indicate that you wanted to send an email to 3 different addresses: "me@mysite.com", "them@theirsite.com", and "$to".  This fact was obscured due to the fact that two of the email addresses were used in one call.

It was pointed out that simply changing the separator between email addresses would fix the problem.  Literally, your original code (the "something like this" part) would change from:
$this->sendMessage("me@mysite.com, them@theirsite.com", $mSubject, $message);
            $this->sendMessage($to, "Thank you", $message_customer);

Open in new window

To:
$this->sendMessage("me@mysite.com; them@theirsite.com", $mSubject, $message);
            $this->sendMessage($to, "Thank you", $message_customer);

Open in new window


The difference is almost nothing and appears to have been completely overlooked.
See my earlier post  - i tried the suggested solutions, they didn't work, mine did. I do want to send to 3 email addresses -

This didn't work:
$this->sendMessage("me@mysite.com; them@theirsite.com", $mSubject, $message);
            $this->sendMessage($to, "Thank you", $message_customer);

This did:

$this->sendMessage("me@mysite.com", $mSubject, $message);
$this->sendMessage("someoneelse@mysite.com", $mSubject, $message);
            $this->sendMessage($to, "Thank you", $message_customer);
still not getting this - I've tried
$this->sendMessage("me@mysite.com;them@theirsite.com", $mSubject, $message);

neither email gets sent.  i'm looking for a cc - the $to variable is sending a confirmation email

function notify_singup($to, $message, $message_customer)
      {
            $mSubject ="New Good Samaritan Hosiptal donation has been received";            
                                    
            
            
            $this->sendMessage("elkinhimer@sbcglobal.net", $mSubject, $message);
            $this->sendMessage($to, "Thank you for your donation to Good Samaritan Hospital", $message_customer);
      }

Open in new window

It seems that the problem exists with the "sendMessage()" method, which was probably throwing errors or otherwise failing because of some sort of testing.  I would venture a guess that the problem is in fact with how it parses the email address, as it is probably only expecting one, when it should be able to explode the first var by ";" (if present) and test all the addresses in that array.

The answer given is more of a work-around: instead of fixing "sendMessage()" to accept multiple email addresses (something that any MTA should be able to handle), the solution was to call the method again.

I'm not trying to be a pain, merely pointing out a problem I saw.  If you still wish to close the question by accepting your own answer, I will not object further.
I see your point crazedsanity. I still think if someone's banging there head against the wall trying to figure this out (it's built into Authorize.net's ARB API ) this at least will offer a work around.
None of the other solutions worked - this one did.