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 ...

Get Wicked Cool PHP 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.