Introduction

Sending email with PHP is easy as long as your Web server is et up to send email. If you're using a Web hosting service or your own Unix computer (like Linux), this shouldn't be a problem. However, if you're running your own Windows or Mac OS X machine, this could be a problem. Not everybody will be able to get his computer to send out email.

All Unix-based machines already have a mail server installed locally at IP address 127.0.0.1.

PHP has the mail() function that works only if the Web server has access to sendmail or another mail server. One way to eanble the mail() function is to set the SMTP (Simple Mail Transfer Proptocol) value in the php.ini configuration file (for Windows only because Windows does not have a local mail server set up by default.). It works only if your ISP has an SMTP address you can use (e.g. for SBC DSL, it's mail.sbcglobal.net). Unfortunately, you can't use this value if your ISP's SMTP server requires authentication. In this case you can use the mail function provided by PHP Extension an Application Library (PEAR). PEAR's Mail package defines an interface and functions for sending email (http://pear.php.net/package/Mail).

For windows, there are a number of free SMTP servers, like PostCast (http://www.postcastserver.com/). You can install one on your computer, and then you'll have a working email.

For Mac, you can get a mail server for Tiger and Leopard (http://www.roadstead.com/software/MailServeForLeopard/). You can use Postfix Enabler fo Tiger and Panther (http://www.roadstead.com/software/PostfixEnabler/).

You can check your php.ini by loading the phpinfo.


E-Mail | Introduction | Sending E-mail | Sending an HTML Message | Sending E-mail with Headers
© 2008: Hann So
email: hso@voyager.deanza.edu