Before you get down and dirty with some communication code, take a step back from the problem for a second. Doing so can give you a better grasp on the obvious outbound communication class hierarchy in front of you, which you will have to write yourself because PHP doesn't provide it. What do all communications have in common?
You can quite reasonably say that all communications have the following:
Recipients one or more people to receive the communication. This communication can be in the form of e-mail addresses, fax numbers, mobile phone numbers, postal addresses, PO boxes, pigeon holes, and so on.
A message the actual body of what you want to send. The message can be transmitted in plain text or HTML (for an e-mail), a letter-sized bitmap (for a fax), 160 characters of text (for a text message), a stream of 11 KHz audio (for an automated phone call), and so on.
On the flip side, you must also understand the differences between the various types of communication. Not all communications have:
Subjects typically, only emails that have subjects.
Content variants e-mails these days are often sent with both HTML and plain text versions entwined in one MIME package (more on this later).
Attachments these are e-mail and text message specific.
Revealing of or differentiation between Carbon and Blind Carbon recipients if you send a fax, text message, or letter to more than one person, nobody will know who else received the message unless you make a list and stick it in the body.
A recipient of an e-mail is a totally different kind of recipient from a recipient of a text message. Take a look at the following table.
Type of communication | Recipient Component | Format |
---|---|---|
| Name | String |
Address | String following RFC822 specification | |
SMS Text Message to cell phone | Number | String, consisting of plus sign, country prefix, and local number |
Fax | Number | String, consisting of Telco-understood telephone number |
Letter | Full Name | String |
House Number | Integer | |
Street | String | |
Town / City | String | |
State | String | |
Zip | String matching USPS ZIP format |