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

php.ini:

SMTP = smtp.company.net
smtp_port = 25

sendmail_from = support@company.net

HTML Page:

<html>
<form method= “post” action= “mail.php” />
<table>
<tr>
<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=” someone@redim.net” 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>
</tr>
<tr>

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

Mail.php:

<?php

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

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

$message = ‘Test Purpose’;
$headers = ‘From: support@company.net’ . PHP_EOL ;

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

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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