Almost in every web application sending automated email by system is the common requirement. So, it’s very common and important part that must be known by developer.
The simple example, when a visitor to your website fills out a enquiry form.
mail function return a boolen value, return true if email sent successfully, false otherwise
mail ($to , $subject , $message, $additional_headers);
$to: This is the first parameter of mail function hold the email address of receiver, the address to which email has to be sent.
$subject: Every email should have subject. This parameter cannot contain any newline characters.
$message: This is the actual body or content of email to send. Please note that every line should be break by \n and every line should not exceed the limit of 70 characters.
$addintional_header: This contain additional header values like From, CC or Bcc etc. This is the optional parameter in mail function.
$to = “firstname.lastname@example.org”;
$subject = “Welcome to Webs Jyoti”;
$txt = “Hi, You received a new enquiry from user. this is an automated mail”;
$headers = “From: email@example.com” . “\r\n” ;
echo “Mail sent successfully”;