[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

send message to 2 email accounts

Posted on 2011-05-11
13
Medium Priority
?
328 Views
Last Modified: 2012-05-11
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);
0
Comment
Question by:phillystyle123
  • 6
  • 3
  • 2
  • +2
13 Comments
 
LVL 10

Expert Comment

by:Tyler Laczko
ID: 35741693
you can seperate multiple email addresses by doing:

$to = "email@domain.com; email2@domain2.com";
0
 
LVL 10

Expert Comment

by:Tyler Laczko
ID: 35741706
basically in the to field concatenate email addresses using the ;
0
 
LVL 11

Expert Comment

by:brutaldev
ID: 35741742
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.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35742102
Uhh, it kind of looks like you want to send the messages to three accounts?  me, them, and whatever address is in $to?
0
 

Author Comment

by:phillystyle123
ID: 35787545
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);
      }
0
 

Accepted Solution

by:
phillystyle123 earned 0 total points
ID: 35787682
this is how you do it:

$this->sendMessage("email1@mysite.com", $mSubject, $message);
            $this->sendMessage("email2@mysite.com", $mSubject, $message);
0
 
LVL 9

Expert Comment

by:crazedsanity
ID: 35787760
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.
0
 

Author Comment

by:phillystyle123
ID: 35787884
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);
0
 
LVL 9

Expert Comment

by:crazedsanity
ID: 35787983
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.
0
 

Author Comment

by:phillystyle123
ID: 35788032
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

0
 
LVL 9

Expert Comment

by:crazedsanity
ID: 35788188
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.
0
 

Author Comment

by:phillystyle123
ID: 35788332
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.
0
 

Author Closing Comment

by:phillystyle123
ID: 35814135
None of the other solutions worked - this one did.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question