By 05/02/2014 47 Comments

How to use mail function in PHP to send mail

Send Emails in php

  • You can sends an email to anyone directly from PHP script
  • mail() function allows you to send emails

Requirements for send an email

  • You have an installed and working email system
  • You have to set configuration settings in php.ini file

In this article we discuss about mail function in php for sending emails.

<?php

$to = "abc@xyz.com"; // receiver/receivers of the email this is Required 

$subject = "subject goes here"; // specified the subject for the email this is Required

$body = "Body of your message here you can use HTML too. e.g.BOLD"; // main body of the email where contents can be defined, you can also use html here

$headers = "From: TutorialsTown\r\n"; // specified from that mail will be send

$headers .= "Reply-To: info@yoursite.com\r\n";

$headers .= "Return-Path: info@yoursite.com\r\n";

$headers .= "X-Mailer: PHP5\n";

$headers .= 'MIME-Version: 1.0' . "\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // describe what types of contents to be send (e.g) text, html, video, pdf etc

mail($to,$subject,$body,$headers); // call mail() method and pass all arguments from it

?>






Posted in: PHP

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .