5.1. Sending E-Mail with PHP

PHP doesn't have any kind of built-in mail-sending function. It relies on the existing mail server — usually Sendmail or Qmail — to do the actual work. The PHP mail extensions simply provide a nice interface to the underlying mail server. To clarify, the PHP mail extensions don't actually tackle the job of sending e-mail. They don't need to because just about every Web server also has an e-mail server installed. Why re-invent a particularly tricky wheel? However, sending commands directly to the e-mail server through PHP would be complicated and a security nightmare. That's where the mail extensions shine. They encapsulate the complexity of sending messages through the e-mail server into a few simple function calls.

5.1.1. Basic e-mail

Sending mail complies with the 80–20 rule: 80 percent of the time, you'll use the most basic 20 percent of the mail features. (Later in this chapter, we get into the more advanced mechanisms, just in case you happen to be in one of those oddball 20 percent situations.)

We start out by covering the basic 20 percent of mail features that you'll use 80 percent of the time. Configuring PHP to send e-mail

The first thing you have to do in order to send e-mail through PHP is make sure it's configured properly by checking the configuration directives listed in this section. If you're running a standard installation of Sendmail, odds are good that everything is ready to go. But just in case, here are the configuration ...

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.