Home >>Advance PHP Tutorial >PHP Mail Function

PHP Mail Function

Sending Email using Php (Text mail Only

Most Popular Intern-ate service Now a days is Email. Thousands of Emails send and received each day.

The PHP Sending Email Tutorial goal's is to demonstrate how to send email.

Sometimes Sending Email by you contains Only Text message, sometimes it contains Some HTML Scripts and sometimes You want to send your mail some message with some attachments.

Sending a Simple Text Email

At First, lets start with Sending a Simple Text Email. The Php mail( ) function is used to send Emails in PHP. Inside mail( ) function you can pass three Basic and one optional Parameters.

Three Basic Parameters : The email address to send(Receiver email), Subject of mail, Content/message of the mail.

Optional Parameters: additional headers you want to include(headers and sender mail)

PHP Script

    $subject ="Mail Function in PHP";
	$message =$name." ".$mobile." ".$query;
    $headers = "From:".$from;
	echo "<h3 align='center'>Mail Sent Successfully</h3>";

HTML Form(enter your personal information which info u want to send)

	<title>Mail function in php - Phptpoint</title>
<form method="post">
 <table align="center" border="1">
	<th>Enter Your name</th>
	<td><input type="text" name="name"/></td>
		<th>Enter Your mobile</th>
		<td><input type="text" name="mobile"/></td>
		<th>Enter Your email</th>
		<td><input type="email" name="email"/></td>
		<th>Enter Your Query</th>
		<td><textarea name="query"></textarea></td>
		<td align="center" colspan="2">
		<input type="submit" value="Send Mail" name="sendmail"/>

In above example , a mail is sent to info@gmail.com which is receiver address and mail is sent by phptpoint. subject,messages and headers are also given.

No Sidebar ads