Space for google add

Write a PHP script to send email to particular user.

 


Write a PHP script to accept following details form a user (To, From,

Subject, Text) and send email to particular user.


seta1email.html

<html>

<form action="seta1email.php" method="post">

<body>

TO<input type="email" name="to"><br>

SUBJECT<input type="text" name="subject"><br>

MESSAGE<input type="text" name="message"><br>

FROM<input type="email" name="from"><br>

<input type="submit" name="submit" value="submit">

</form>

</body>

</html>




seta1email.php

<html>

<head><title>SENDING EMAIL BY PHP</title></head>

<body>

<?php

$to=$_POST['to'];

$from=$_POST['from'];

$header="From:$from\r\n";

$subject=$_POST['subject'];

$message=$_POST['message'];

$ans=mail($to,$subject,$message,$header);

if($to==null || $from==null)

{

echo "TO AND FROM FIELDS CANNOT BE NULL";

}

else if($message==null)

{

echo "MESSAGE CANNOT BE NULL";

}

else if($ans==true)

{

echo "mail send successfully";

}

else

echo "mail not  send successfully";

}

?>

</body>

</html>


Post a Comment

0 Comments