O'Reilly logo

Wicked Cool PHP by Brian Ward, William Steinmetz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. WORKING WITH EMAIL

WORKING WITH EMAIL

You won't need to manipulate much email in PHP, but one thing that you will need to do is send confirmation messages to users and administrators about account settings, orders, and so on. The easiest way to send email in PHP is with the mail() function. If your mail server is set up correctly, and you need only to send messages to yourself, then this is probably the only function you'll ever need.

Here's a simple script to illustrate how mail() works. Replace with a working email address:

if (mail('user@example.com', 'PHP email test', 'It worked!')) { echo "Mail sent."; } else { echo "Mail delivery failed."; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required