PHP E-Mail

E-Mail is an abbreviation of Electronic Mail, it is a method of passing, exchanging of thoughts.

PHP E-Mail


E-Mail is an abbreviation of Electronic Mail, it is a method of passing, exchanging of thoughts. With the help of E-mail we can send  various types of attachments, like .doc, .xls. .pdf etc. file

With the help of PHP we can send mails to another person. Given example will illustrates the way we can send mail, in the current example we use, PHP, JavaScript, and html scripts.

(Note: The given example is just a program to send mail, but it is not sufficient enough to send mail to another mail address, we need mail server and various other application to send a mail successfully )








$from="[email protected]";


mail($to,$subject, $msg,$headers);

echo"Mail successfully sent";







My Email


<script type="text/javascript">


function validation()


var to=document.form.user.value;

var filter=/^[email protected]+\..{2,3}$/

var sub=document.form.subject.value;

if (filter.test(to) )


else {

alert("Please input a valid email address!")






alert("subject is blank");

return false;



return (testresults)







<form name="form" onsubmit="return(validation())" action="mailPhp.php">



<td>To:</td><td><input type="text" name="user" ></td>



<td>Subject:</td><td><input type="text" name="subject"></td>




<td><textarea name='msg' rows="8" cols="12"></textarea></td>



<td><input type ="submit" value="submit"></td>

<td><input type="reset" value="Reset"></input></td>







<?php }?>



If we left the subject box and to box blank or the email address is wrong, then alert box will be generated.


Since we did not install the mail server, output will be as follows:
Mail successfully sent




We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.

Share on Google+Share on Google+

PHP E-Mail

Posted on: November 12, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: PHP E-Mail  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
December 5, 2011
I'm in need help in using php and mysql

I'm in need help in using php and mysql.I want to know how to get permium user
February 9, 2012
for advice

this code is very help full for creating email
December 13, 2012
Gmail compose mail plugins

i want to click the send button plugins to gmail compose mail to open the gmail compose mail send using php code