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
Is overloading possible in php?
Will a comparison of an integer 12 and a string "13" work in php?
When a conditional statement is ended with an endif?
What is strcmp () in php?
How to check curl is enabled or not in PHP
Explain what is the difference between for and foreach?
What is the use of header() function in PHP? What the Limitation of HEADER()?
How to set session.gc_maxlifetime properly?
What does $_env means?
Tell me what is htaccess?
How can you retrieve a cookie value?
What is string and its function?
What do you mean by having php as whitespace insensitive?
What is faster in php?
What is the difference between html and php?