Wednesday, April 12, 2006

IERI R3: Sending mail via PHP

The mail functionality included in PHP by default is pretty light. There's not much functionality for making it easy to produce e-mail messages that conform to standards. Just one example is the lack of wrapping long lines in the body. I found a function online that will format text as quoted-printable, though it had to be modified to take into account line length requirements. I think it can probably be simplified a bit, but my concern at present is making the system functionally complete ... code efficiency, scalability, and performance will need to wait for another day.

Note: There's also a function for quoted-printable encoding in the comments for the mail() function, but it also does not take into account line-length requirements.

The built-in mail() function appears to be susceptible to manipulation by user-submitted data for the purposes of SPAM or other causes (see the comments for the mail() function). While this isn't a big concern with IERI it's something that needs to be kept in mind if I plan on using this function in the future. I found some information that will provde useful in weeding out SPAM hacks such as detecting newline characters and e-mail header text.

Unfortunately the e-mail functionality I've developed based on mail() and other functions is pretty limited in scope. The PEAR project appears to have a fairly full-featured mail package. I don't think it will be necessary to install for use with IERI, however, as e-mail is not the core purpose of the utility. Unless additional functionality needs are required down the line I'll probably stick with what I've developed so far.