CHAPTER 16 ?– NETWORKING 413
On the Unix platform, PHP??™s mail() function is dependent upon the sendmail
MTA. If you??™re using an alternative MTA (e.g., qmail), you need to use that MTA??™s sendmail
wrappers. PHP??™s Windows implementation of the function instead depends
upon establishing a socket connection to an MTA designated by the SMTP configuration
directive, introduced in the previous section.
The remainder of this section is devoted to numerous examples highlighting the many
capabilities of this simple yet powerful function.
Sending a Plain-Text E-mail
Sending the simplest of e-mails is trivial using the mail() function, done using just the
three required parameters. Here??™s an example:
mail("test@example.com", "This is a subject", "This is the mail body");
?>
Try swapping out the placeholder recipient address with your own and executing
this on your server. The mail should arrive in your inbox within a few moments. If
you??™ve executed this script on a Windows server, the From field should denote whatever
e-mail address you assigned to the sendmail_from configuration directive. However,
if you??™ve executed this script on a Unix machine, you might have noticed a rather odd
From address, likely specifying the user nobody or www. Because of the way PHP??™s mail
function is implemented on Unix systems, the default sender will appear as the same
user under which the server daemon process is operating.
Pages:
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494