Mail functions Mail The mail function allows you to send mail mail send mail Description bool mail string to string subject string message string additional_headers string additional_parameters Mail automatically mails the message specified in message to the receiver specified in to. Multiple recipients can be specified by putting a comma between each address in to. mail returns TRUE if the mail is sucessfully sent, FALSE otherwise. Sending mail. mail("rasmus@lerdorf.on.ca", "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. 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@aol.com", "the subject", $message, "From: webmaster@$SERVER_NAME\nReply-To: webmaster@$SERVER_NAME\nX-Mailer: PHP/" . phpversion()); With the fifth parameter you can set additional command line parameters to the actual mailer. In the example below we set the correct Return-Path header for 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 config file. This fifth parameter was added in PHP 4.0.5. Sending mail with extra headers and setting an additional command line parameter. mail("nobody@aol.com", "the subject", $message, "From: webmaster@$SERVER_NAME", "-fwebmaster@$SERVERNAME"); You can also use fairly simple string building techniques to build complex email messages. Sending complex email. /* recipients */ $recipient .= "Mary <mary@u.college.edu>" . ", " ; //note the comma $recipient .= "Kelly <kelly@u.college.edu>" . ", "; $recipient .= "ronabop@php.net"; /* 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 copylefted by public domain"; /* additional header pieces for errors, From cc's, bcc's, etc */ $headers .= "From: Birthday Reminder <birthday@php.net>\n"; $headers .= "X-Sender: <birthday@php.net>\n"; $headers .= "X-Mailer: PHP\n"; // mailer $headers .= "X-Priority: 1\n"; // Urgent message! $headers .= "Return-Path: <birthday@php.net>\n"; // Return path for errors /* If you want to send html mail, uncomment the following line */ // $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type $headers .= "cc:birthdayarchive@php.net\n"; // CC to $headers .= "bcc:birthdaycheck@php.net, birthdaygifts@php.net\n"; // BCCs to /* and now mail it */ mail($recipient, $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. ezmlm_hash Calculate the hash value needed by EZMLM Description int ezmlm_hash string addr ezmlm_hash calculates the hash value needed when keeping EZMLM mailing lists in a MySQL database. Calculating the hash and subscribing a user $user = "kris@koehntopp.de"; $hash = ezmlm_hash ($user); $query = sprintf ("INSERT INTO sample VALUES (%s, '%s')", $hash, $user); $db->query($query); // using PHPLIB db interface