From bee07ad3a70674cf21456038634ec0a46cd982f5 Mon Sep 17 00:00:00 2001 From: jim winstead Date: Wed, 31 Oct 2001 23:51:29 +0000 Subject: [PATCH] clean up mail() documentation. move mail-related ini stuff to functions/mail.xml from chapters/config.xml. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@61277 c90b9560-bf6c-de11-be94-00142212c4b1 --- chapters/config.xml | 56 +-------------- functions/mail.xml | 161 ++++++++++++++++++++++++++++++-------------- 2 files changed, 112 insertions(+), 105 deletions(-) diff --git a/chapters/config.xml b/chapters/config.xml index 75fda35508..deec1e9d77 100644 --- a/chapters/config.xml +++ b/chapters/config.xml @@ -1,5 +1,5 @@ - + Configuration @@ -695,60 +695,6 @@ include_path=".;c:\www\phplib" - - Mail Configuration Directives - - - - - SMTP - string - - - - DNS name or IP address of the SMTP server PHP under Windows - should use for mail sent with the mail - function. - - - - - - sendmail_from - string - - - - Which "From:" mail address should be used in mail sent from - PHP under Windows. - - - - - - sendmail_path - string - - - - Where the sendmail program can be found, - usually /usr/sbin/sendmail or - /usr/lib/sendmail - configure does an honest attempt of - locating this one for you and set a default, but if it fails, - you can set it here. - - Systems not using sendmail should set this directive to the - sendmail wrapper/replacement their mail system offers, if any. - For example, Qmail - users can normally set it to - /var/qmail/bin/sendmail. - - - - - - Safe Mode Configuration Directives diff --git a/functions/mail.xml b/functions/mail.xml index bb5991fc92..aa4b33f4d5 100644 --- a/functions/mail.xml +++ b/functions/mail.xml @@ -1,5 +1,5 @@ - + Mail functions Mail @@ -7,6 +7,57 @@ The mail function allows you to send mail + + + Mail Configuration Directives + + + + SMTP + string + + + + DNS name or IP address of the SMTP server PHP under Windows + should use for mail sent with the mail + function. + + + + + + sendmail_from + string + + + + Which "From:" mail address should be used in mail sent from + PHP under Windows. + + + + + + sendmail_path + string + + + + Where the sendmail program can be found, + usually /usr/sbin/sendmail or + /usr/lib/sendmail + configure does an honest attempt of + locating this one for you and set a default, but if it fails, + you can set it here. + + Systems not using sendmail should set this directive to the + sendmail wrapper/replacement their mail system offers, if any. + For example, Qmail + users can normally set it to + /var/qmail/bin/sendmail. + + + @@ -57,43 +108,38 @@ mail("joecool@example.com", "My Subject", "Line 1\nLine 2\nLine 3"); If a fourth string argument is passed, this string is inserted at the end of the header. This is typically used to add extra - headers. Multiple extra headers are separated with a newline. + headers. Multiple extra headers are separated with a carriage return + and newline. - On Win32 systems, you must use \r\n to - seperate headers. Please also note that the cc: and bcc: headers - are case sensitve and should be written as Cc: - and Bcc: on Win32 systems. + You must use \r\n to seperate headers, although + some Unix mail transfer agents may work with just a single newline + (\n). The Cc: header is case sensitive and must + be written as Cc: on Win32 systems. The Bcc: + header is also not supported on Win32 systems. - - If the fifth parameter is supplied, PHP will add this data - to the call to the mailer. This is useful when setting the - correct Return-Path header when using sendmail. - Sending mail with extra headers. mail("nobody@example.com", "the subject", $message, - "From: webmaster@$SERVER_NAME\nReply-To: webmaster@$SERVER_NAME\nX-Mailer: PHP/" . phpversion()); + "From: webmaster@$SERVER_NAME\r\n" + ."Reply-To: webmaster@$SERVER_NAME\r\n" + ."X-Mailer: PHP/" . phpversion()); - With the fifth parameter you can set additional command line - parameters to the mail program. In the example below we set the - correct Return-Path header when using sendmail. Normally sendmail - will add the X-Authentication-Warning header when using the -f - parameter, because the webserver user is probably not a member of - the trusted users. To suppress this warning, you should add the web - server user to the trusted users in your sendmail configuration file. - - - This fifth parameter was added in PHP 4.0.5. - - + The additional_parameters parameter + can be used to pass additional parameters to the program configured + to use when sending mail using the sendmail_path + configuration setting. For example, this can be used to set the + envelope sender address when using sendmail. You may need to add + the user that your web server runs as to your sendmail configuration + to prevent a 'X-Warning' header from being added to the message when + you set the envelope sender using this method. Sending mail with extra headers and setting an additional command line parameter. @@ -101,51 +147,66 @@ mail("nobody@example.com", "the subject", $message, "From: webmaster@$SERVER_NAME", "-fwebmaster@$SERVER_NAME"); - You can also use fairly simple string building techniques to - build complex email messages. + + + + This fifth parameter was added in PHP 4.0.5. + + + + You can also use simple string building techniques to build complex + email messages. Sending complex email. /* recipients */ -$recipient .= "Mary <mary@example.com>" . ", " ; //note the comma -$recipient .= "Kelly <kelly@example.com>"; +$to = "Mary <mary@example.com>" . ", " ; //note the comma +$to .= "Kelly <kelly@example.com>"; /* subject */ $subject = "Birthday Reminders for August"; /* message */ -$message .= "The following email includes a formatted ASCII table\n"; -$message .= "Day \t\tMonth \t\tYear\n"; -$message .= "3rd \t\tAug \t\t1970\n"; -$message .= "17rd\t\tAug \t\t1973\n"; - -/* you can add a stock signature */ -$message .= "-- \r\n"; //Signature delimiter -$message .= "Birthday reminder"; - -/* additional header pieces for errors, From cc's, bcc's, etc */ - -$headers .= "From: Birthday Reminder <birthday@example.com>\n"; -$headers .= "X-Sender: <birthday@example.com>\n"; -$headers .= "X-Mailer: PHP\n"; // mailer -$headers .= "X-Priority: 1\n"; // Urgent message! -$headers .= "Return-Path: <birthday@example.com>\n"; // Return path for errors +$message = ' +<html> +<head> + <title>Birthday Reminders for August</title> +</head> +<body> +<p>Here are the birthdays upcoming in August!</p> +<table> + <tr> + <th>Person</th><th>Day</th><th>Month</th><th>Year</th> + </tr> + <tr> + <td>Joe</td><td>3rd</td><td>August</td><td>1970</td> + <td>Sally</td><td>17th</td><td>August</td><td>1973</td> + </tr> +</table> +</body> +</html> +'; /* To send HTML mail, you can set the Content-type header. */ -// $headers .= "Content-type: text/html; charset=iso-8859-1\n"; +$headers = "MIME-Version: 1.0\r\n"; +$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; -$headers .= "Cc: birthdayarchive@example.com\n"; -$headers .= "Bcc: birthdaycheck@example.com\n"; +/* additional headers */ +$headers .= "From: Birthday Reminder <birthday@example.com>\r\n"; + +$headers .= "Cc: birthdayarchive@example.com\r\n"; +$headers .= "Bcc: birthdaycheck@example.com\r\n"; /* and now mail it */ -mail($recipient, $subject, $message, $headers); +mail($to, $subject, $message, $headers); - Make sure you have no new-line (or other whitespace) after your to or - subject parameters, as this may cause strange results. + Make sure you do not have any newline characters in the + to or subject, + or the mail may not be sent properly.