PHP tutorials, html tutorial, photoshop tutorial, ajax tutorials,java tutorial, web design tips tutorials, css tutorial, visual basic tutorial, dreamweaver tutorial, php tutorial, html tutorials, c++ tutorial, javascript tutorial, windows tutorials, free flash tutorials, free photoshop source codes, sql tutorial
Web Development Tutorials, Programming Tutorials, PHP Script Index
Home | Forums | Downloads | Books | Submit Content | Links

Programming Articles

  PHP articles
  MySql articles
  Visual Basic.Net articles
  Java articles
  ASP articles
  ASP.Net articles
  Visual Basic articles
  CSS articles

Programming Tutorials

  PHP tutorials
  MySql tutorials
  Visual Basic.Net tutorials
  Java tutorials
  ASP tutorials
  ASP.Net tutorials
  Visual Basic tutorials
  HTML tutorials
  CSS tutorials

Programming Source Codes

  PHP scripts
  Visual Basic.Net scripts
  JavaScript scripts
  ASP scripts
  ASP.Net scripts
  Visual Basic scripts

Our Partners

  Free Resources
  Publisherbank
  Free Link Directory
  PHP Magazine
  Webmaster Passion
  Search Engine Bank
  Free Directory Site
  Free PHP Scripts
  Links Shopping Mart
  Variety Bazar
  Urdu Office Tutorials
  Evernew Scripts
  Evernew Scripts
  Evernew Directory
  Our Achievements
  Web templates
  Buy and Sell Templates
  Text Link Traders
  Directory Metro
  Gifts Choice
  Valentines Ecards
  Template Directory

Email in PHP

Date:2006-03-20

PHP has a very useful built-in function called mail(), which is used to send email. The syntax of variable

<?php
mail(receiver,subject, message, additional parameters);
?>
  • In receiver parameter we enter the email address of recipient.
  • In message parameter we will enter the subject of email.
  • In message parameter we will enter the message of email.
  • additional parameters is an optional parameter but it is used for email address of sender.

E-Mail Form:

Now we will create a simple email form, for this purpose we will use 2 files

  • mailform.html
  • sendmail.php

In mailform.html we will design a for layout as follows:

<form name="form1" method="post" action="sendmail.php">
<table width="394" align="center">
<tr>
<td width="36%"> <div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Your
Name</b></font></div></td>
<td width="64%"> <input name="sender" type="text" id="name" size="40" maxlength="100"></td>
</tr>
<tr>
<td align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Your
Email </b></font></td>
<td><input name="receiver" type="text" id="email" size="40" maxlength="100"></td>
</tr>
<tr>
<td width="36%"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Subject</b></font></div></td>
<td width="64%">
<input name="subject" type="text" id="email" size="40" maxlength="100">
</td>
</tr>
<TR>
<TD WIDTH="36%"><DIV ALIGN="right"><FONT SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif"><B>Message:
</B></FONT></DIV></TD>
<TD WIDTH="64%"><textarea name="message" cols="35" rows="5" id="message"></textarea>
</TD>
</TR>
<tr>
<td width="36%">&nbsp;</td>
<td width="64%"><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>

Now we will enter email sending related code in sendmail.php

<?php

if ($submit){
if ($email == "") {
echo "<font size=3 face=Arial><B>ERROR!!</b></font><font size='2' face='arial'>Please enter your email address. Thank you!</font>";exit;}

mail("$receiver","$subject", $message, "From:$sender<$sender>");

print "Email has successfully send";
}

?>



Desclaimer | Privacy Policy | Submit Content | Links | Link to Us | Sitemap |Contact Us
Copyright Programming Tutorials, Web Development Tutorials, Source codes © All Rights are Reserved.
Powered By Evernew Solutions

Cheap Flights - Mortgages - Loans - Loans