Handling Incoming Mail to Multiple Recipients in PHP
Posted
by Navarr
on Stack Overflow
See other posts from Stack Overflow
or by Navarr
Published on 2010-03-30T12:59:37Z
Indexed on
2010/03/30
13:03 UTC
Read the original article
Hit count: 394
Alright, this may take a moment or two to explain:
I'm working on creating an Email<>SMS Bridge (like Teleflip). I have a few set parameters to work in:
- Dreamhost Webhosting
- PHP 5 (without PEAR)
- Postfix
What I have right now, is a catch-all email address that forwards the email sent to a shell account. The shell account in turn forwards it to my PHP script.
The PHP script reads it, strips a few Email Headers in an effort to make sure it sends properly, then forwards it to the number specified as the recipient. [email protected] of course sends an SMS to +1 (555) 123-4567.
This works really well, as I am parsing the To field and grabbing just the email address it is sending to. However, what I realized that I did not account for is multiple recipients. For example, an email sent to both 5551234567 and 1235554567 (using the To line, the CC line, or any combination of those).
The way email works of course, is I get two emails received, end up parsing each of them separately, and 5551234567 ends up getting the same message twice.
What is the best way to handle this situation, so that each number specified in TO and CC can get one copy of the message.
In addition, though I doubt its possible: Is there a way to handle BCC the same way?
© Stack Overflow or respective owner