How to use the sendmail option on PHP
Websites often need to send mail to certain user accounts for purposes like email-id verification, sending newsletters and updates, or sending account details. The PHP programming language has the mail() function to send mail to any Email address. It uses the SMTP protocol for sending mail.
Syntax of the sendmail function
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
The variables explained
The variable $to signifies the email address to which the mail is being sent. Some examples are:
- email@example.com, firstname.lastname@example.org
- User <email@example.com>
- User <firstname.lastname@example.org>, Another User <email@example.com>
The variable $subject supplies the subject of the email sent .
The string $message contains the entire body of the message.
$additional_headers is used to supply additional headers with the mail, for example the from header, or the Reply-To header. The headers are seperated with CRLF ( carriage-return linefeed ) sequences.
An example use of the sendmail function –
$to = ”firstname.lastname@example.org”;
$subject = ”testing”;
$message = “hello world!”;
BounceWeb provides great deals on PHP web hosting!
Leave a Reply
You must be logged in to post a comment.