How to Send E-Mail using PHP script

This article explains about sending a simple mail using PHP mail function.

Creating a Email Form using HTML

 

PHP Code For Handling Action and Send Email

if(count($_POST) > 0)
{
 $sender_email = $_POST["sender_email"];
 $receipent_email = $_POST["receipent_email"];
 $email_subject = $_POST["email_subject"];
 $message = $_POST["message"];
 $result = mail($receipent_email, $email_subject, $message,"From: $sender_email\n");
 if($result) {
    echo "Mail has been send successfully.";
 }
 else {
    echo "There was a problem in sending email.";
 }
}

This is just a method of how to send a simple email using PHP. In above script there is no way of proper error checking and other advance email functionalities like sending of HTML email, custom headers.

Ashesh

सयौ थुङ्गा फूलका हामी एउटै माला नेपाली, Welcome to my webpage. I'm from the Himalayan Country of Nepal. Well talking about me, I like mostly Web programming and Designing and furthermore I like Philosophical literature, Photography, Social networking. And I am Romantic and Sentimental person to some extent. Read more...