Send Mail to an email that entered in text box

Today we will see how to send a mail that has been entered in a textbox through PHP 🙂

In Order to first send mail..add few fields in php.ini


smtp_port = 25

sendmail_from =

HTML Page:

<form method= “post” action= “mail.php” />
<td> Enter E-Mail :<br/>
&nbsp;<div style=”background-image:url(‘./username1.png’);width:322px; height:35px;background-repeat:no-repeat; “>
<div style=”padding-left:0px;”><input type=”text” id=”to” name=”to” placeholder=”” style=”font-family: Trebuchet MS;font-size: 14px;background:none;border:none; width:314px; height:28px;padding-left:6px;padding-top:3px;outline: none;” /></div>

<td><input name= “email” type= “image” value= “Send” src=”submit.png”/></td>



if ( isset ( $_POST [ ’email’ ])){

$to = $_POST [ “to” ];
$subject = ‘Your Company Login Details’ ;

$message = ‘Test Purpose’;
$headers = ‘From:’ . PHP_EOL ;

mail ( $to , $subject , $message , $headers );
echo “Check your email!!” ;}
else {
echo”try again”;
} ?>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s