|
![]() |
The Php mail() function
People often get all worked up about getting the Php mail function to work.
There are lots of complicated scripts out there to send mail but it really is not that hard.
Here is the simplest way to do it.
The Easiest Way to Send Mail with Php
Example Code |
---|
<?php mail( 'you@yoursite.com', 'Subject Line', 'Text of the Message.' ); ?>
|
This is probably the quickest, easiest way of sending mail with Php. However,
you might want something more sophisticated. For example, maybe you want
to set the "from" address or the likes. Well here you go.
How to Send Extra Headers
Example Code |
---|
<?php // Put the info into some variables
$to_address = 'you@yourdomain.com';
$subject = 'Subject - Enquiry';
$extra_headers = "From: $NAME_OF_SENDER <$EMAIL_OF_SENDER>\r\n";
$extra_headers .= "Reply-To: $EMAIL_OF_SENDER\r\n";
$extra_headers .= "Return-Path: $EMAIL_OF_SENDER\r\n";
$message = 'Blah Blah Blah';
// Call the mail function with the variables.
mail( $to_address, $subject, $message, $extra_headers ); ?>
|
In this example the variables $NAME_OF_SENDER and $EMAIL_OF_SENDER would need to
be set before mailing. Normally you could use and HTML form element to pass the
data to the script and then send the email based on that.
|
|