11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 16 • NETWORKINGwww.it-ebooks.infoKeep in mind that this directive only applies to the Unix platform. Windows depends uponestablishing a socket connection to an SMTP server specified by the SMTP directive on port smtp_port.smtp_port = integerScope: <strong>PHP</strong>_INI_ALL; Default value: 25The smtp_port directive sets the port used to connect to the server specified by the SMTP directive.mail.force_extra_parameters = stringScope: <strong>PHP</strong>_INI_SYSTEM; Default value: NULLYou can use the mail.force_extra_parameters directive to pass additional flags to the sendmailbinary. Note that any parameters passed here will replace those passed in via the mail() function’saddl_params parameter.Sending E-mail Using a <strong>PHP</strong> ScriptE-mail can be sent through a <strong>PHP</strong> script in amazingly easy fashion, using the mail() function. Itsprototype follows:boolean mail(string to, string subject, string message [, string addl_headers[, string addl_params]])The mail() function can send an e-mail with a subject and a message to one or several recipients.You can tailor many of the e-mail properties using the addl_headers parameter; you can even modifyyour SMTP server’s behavior by passing extra flags via the addl_params parameter.On the Unix platform, <strong>PHP</strong>’s mail() function is dependent upon the sendmail MTA. If you’re usingan alternative MTA (e.g., qmail), you need to use that MTA’s sendmail wrappers. <strong>PHP</strong>’s Windowsimplementation of the function depends upon establishing a socket connection to an MTA designatedby the SMTP configuration directive, introduced in the previous section.The remainder of this section is devoted to numerous examples highlighting the many capabilitiesof this simple yet powerful function.Sending a Plain-Text E-mailSending the simplest of e-mails is trivial using the mail() function, done using just the three requiredparameters, in addition to the fourth parameter which allows you to identify a sender. Here’s anexample:Take particular note of how the sender address is set, including the \r\n (carriage return plus linefeed) characters. Neglecting to format the address in this manner will produce unexpected results orcause the function to fail altogether.340

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!