@: No, I don't think you were wrong. The issue was that the OP wasn't handling the [man]array[/man] being passed back properly, and you gave some example code of how it could be properly handled. Whether or not the e-mail is plain text, HTML, or BlargityBlargBlarg is irrelevant.
SteveMTNO wrote:What do you recommend - just change the variable names to something else?
Er... do you really think that "just [changing] the variable names to something else" is actually doing to prevent anything dalecosp talked about in any way? If bank robbers took over a bank, do you think the bank manager would say "Safe?? Oh no, that's not a safe, we call that the big shiny door to the bathroom" ? 😉
For #1, you actually can't check if the mail was sent succesfully in PHP or any other programming language. You can, however, check to see if the MTA accepted your message (meaning you know it will at least try to send it - perhaps unsuccessfully, but there's no way of knowing that). To do this, you should be checking the value that [man]mail/man returns (see the manual to learn what it returns).
For #2, dalecosp is referring to what's commonly called a "header injection attack." In other words, if I said my e-mail address was:
brad@example.com>
Bcc: spamvictim1@example.com, spamvictim2@example.com, ..., <spamvictim9999@example.com
then your e-mail message header would look like:
From: Brad <brad@example.com>
Bcc: spamvictim1@example.com, spamvictim2@example.com, ..., <spamvictim9999@example.com>
MIME-Version: 1.0
...
and you've now become an open mail relay, something that will most likely get your server blacklisted very quickly (meaning even your legitimate e-mails will automatically be considered spam and thrown in the trash).
To get around this, never insert user-supplied data into e-mail headers without sanitizing it first. For example, you could verify that their e-mail address is valid and that none of their inputs contain line breaks.