Skip to Content
PHP6 and MySQL® 6 Bible
book

PHP6 and MySQL® 6 Bible

by Tim Converse, Steve Suehring, Joyce Park
January 2009
Intermediate to advanced
911 pages
20h 32m
English
Wiley
Content preview from PHP6 and MySQL® 6 Bible

Chapter 37. Sending E-Mail with PHP

This chapter is all about using PHP (and, in some cases, databases) to send e-mail. If you're looking to receive e-mail with PHP, by using a protocol such as POP3 or IMAP, please refer to the PHP manual for those functions.

Sending E-Mail with PHP

Sending mail is where PHP really comes into its own. But before you can send any mail from your server, you need to tweak the configuration file a little.

Windows configuration

In Windows, you need to set two variables in the php.ini file:

  • SMTP: A string containing the DNS name or IP address of an SMTP server that relays for the Windows machine on which PHP is installed. If it is on the PHP server, specify localhost.

  • sendmail_from: A string containing the e-mail address of your default PHP mail sender (for example, ).

    Tip

    IIS4+ has an SMTP server built in, which is lighter than Exchange Server, if you don't need the power of the latter.

Linux configuration

You need to check and possibly change one variable in the php.ini file if you're using Unix: sendmail_path, a string containing the full path to your sendmail program (usually /usr/sbin/sendmail or /usr/lib/sendmail), a replacement, or a wrapper (such as /var/qmail/bin/sendmail).

The mail function

The mail() function is the primary function used to send mail with PHP. This function, which returns a Boolean, attempts to send one message using the data within the parentheses. The ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Beginning PHP 5.3

Beginning PHP 5.3

Matt Doyle
PHP 7: Real World Application Development

PHP 7: Real World Application Development

Doug Bierer, Altaf Hussain, Branko Ajzele
MySQL®

MySQL®

Paul DuBois

Publisher Resources

ISBN: 9780470384503Purchase book