please explain me mail function in php

Answer Posted / nirjesh pandey

The PHP mail() Function:

The PHP mail() function is used to send emails from inside a
script.

Syntax
mail(to,subject,message,headers,parameters)

Parameter Description
to Required. Specifies the receiver / receivers of the email
subject Required. Specifies the subject of the email. Note:
This parameter cannot contain any newline characters
message Required. Defines the message to be sent. Each line
should be separated with a LF (\n). Lines should not exceed
70 characters
headers Optional. Specifies additional headers, like From,
Cc, and Bcc. The additional headers should be separated with
a CRLF (\r\n)
parameters Optional. Specifies an additional parameter to
the sendmail program

Note: For the mail functions to be available, PHP requires
an installed and working email system. The program to be
used is defined by the configuration settings in the php.ini
file. Read more in our PHP Mail reference.
PHP Simple E-Mail

The simplest way to send an email with PHP is to send a text
email.

In the example below we first declare the variables ($to,
$subject, $message, $from, $headers), then we use the
variables in the mail() function to send an e-mail:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

Is This Answer Correct ?    8 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What language is php written in?

583


Why php is also called as scripting language?

548


What are advantages of .htaccess?

527


Explain the importance of the function htmlentities.

539


What does $_env mean?

567






What are the different types of statements that are present in php?

543


How do I stop a php script?

497


Tell me what are sql injections, how do you prevent them and what are the best practices?

507


Which function is used in php to count the total number of rows returned by any query?

518


What is polymorphism?

2067


Explain about switch statement in PHP?

588


Are sessions stateless?

484


Tell me is it possible to submit a form with a dedicated button?

527


Is set in php?

545


What does type casting mean in php? Explain with an example?

541