String Manipulation and Regular Expressions CHAPTER 4 95 LISTING Continued mail($toaddress, $subject, $mailcontent, $fromaddress); ? Bob’s Auto Parts - Feedback Submitted Feedback submitted Your feedback has been sent. 4 STRING MANIPULATION FIGURE Bob’s feedback form asks customers for their name, email address, and comments. Note that generally you should check that users have filled out all the required form fields using, for example, isempty(). We have omitted this from the script and other examples for the sake of brevity. In this script, you’ll see that we have concatenated the form fields together and used PHP’s mail() function to email them. | String Manipulation and Regular Expressions 95 Chapter 4 Listing Continued mail toaddress subject mailcontent fromaddress html head title Bob s Auto Parts - Feedback Submitted title head body h1 Feedback submitted h1 p Your feedback has been sent. p body html Figure Bob s feedback form asks customers for their name email address and comments. 4 Note that generally you should check that users have filled out all the required form fields using for example isempty . We have omitted this from the script and other examples for the sake of brevity. In this script you ll see that we have concatenated the form fields together and used PHP s mail function to email them to feedback@. We haven t yet used mail so we will discuss how it works. String Manipulation 96 Using PHP Part I Unsurprisingly this function sends email. The prototype for mail looks like this bool mail string to string subject string message string additional_headers The first three parameters are compulsory and represent the address to send email to the subject line and the message contents respectively. The fourth parameter can be used to send any additional valid email headers. Valid email headers are described in the document RFC822 which is available online if you want more details. RFCs or Requests For Comment are the source of many Internet standards we will discuss them in Chapter 17 Using Network and Protocol Functions. Here we ve used the fourth parameter to add a From address for the mail. You can also use to it add Reply-To and Cc fields among others. If you want more than one additional header just separate them by newlines n within the string as follows additional_headers From webserver@ n . Reply-To bob@ In order to use the email function set up your PHP installation to point at your mail-sending program. If the script doesn t work for you in its current form double-check Appendix A Installing PHP 4 and MySQL. Through this chapter we ll enhance