PHP mail() function
Published on 11/27/2008 by Dotnetindex|
Vote this tutorial:
|
More articles in PHP
Following example uses PHP builtin function mail(). Function gets three parameter. Target email, subject and message. Default type is text. But you can enter custom headers: From, Cc, and Bcc. Multiple extra headers should be separated with a CRLF (\r\n).
Mail function returns a boolean value.
Syntax:
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
<?php
// email address
$email = "info@dotnetindex.com";
// The email subject
$subject = "Enter your subject here";
// The message body (TEXT)
$message = "Enter your message here";
mail($email, $subject, $message, "From: $email");
echo "The email has been sent.";
?>
With additional headers:
<?php
$to = 'someone@gazatem.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@dotnetindex.com' . "\r\n" .
'Reply-To: webmaster@dotnetindex.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
$to = 'someone@gazatem.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@dotnetindex.com' . "\r\n" .
'Reply-To: webmaster@dotnetindex.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
You can get more information at this page.
Comments:
no comments submitted
Latest Posts
- Database driven web counter with PHP/mySQL
- PHP mail() function
- Workingwith Arrays in PHP
- Check if the domain name exists
- Generating random strings within PHP
- Encode/Decode an ISO-8859-1 string to UTF-8
- Creating error pages using .htaccess
- PHP Security
- Displaying mySQL table structures in PHP
- Capitilize strings in PHP
- Counting records in PHP mySQL
- Parsing XML/RSS feeds easily with SimpleXML
- Sending queries to mySQL
- Session in PHP
- MD5 Encryption in PHP
- PHP Functions array fill
- How to display date time in real time
- PHP Functions urlencode
- In Case You Missed ItThe Week of January 23 2006
- In Case You Missed ItThe Week of January 16 2006


