Sending Email
One of my absolute favorite things about PHP is how easy it is to send an email. On a properly configured server, the process is as simple as using the mail() function.
mail ($to, $subject, $body);
The $to value should be an email address or a series of addresses, separated by commas. The $subject value will create the email’s subject line, and $body is where you put the contents of the email. Use the newline character (\n) within double quotation marks when creating your body to make the text go over multiple lines.
The mail() function takes a fourth, optional parameter for additional headers. This is where you could set the From, Reply-To, Cc, Bcc, and similar settings. For example,
mail ('phpmysql2@dmcinsights.com', → 'Question ...
Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition 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.