[an error occurred while processing this directive]

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 )










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=/^.+@.+\..{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


[an error occurred while processing this directive]