Page 535 - Beginning PHP 5.3
P. 535
Chapter 16: PHP and the Outside World
Figure 16-3
Sending Email
Many Web applications have a need to send email messages. For example, a contact form script typically
processes a form submitted by a visitor and emails the form information to the Webmaster. Other
common scenarios include “ tell a friend ” functions, as well as member registration and “ forgotten
password ” functions that email information to members.
PHP includes built - in support for creating and sending email messages, which makes it very easy to
send email from within your PHP scripts.
To send an email message in PHP, you use the mail() function. On Unix servers such as Linux and Mac
OS X, PHP uses the operating system ’ s built - in mail transfer agent (MTA) to send the email. (Common
MTAs include sendmail , postfix , and exim .) On non - Unix servers such as Windows, PHP talks
directly to an SMTP mail server (either on the server or on another machine).
497
9/21/09 9:15:38 AM
c16.indd 497
c16.indd 497 9/21/09 9:15:38 AM