Wednesday, 5 June 2013

Simple Email in PHP

simpleEmail.php

<?php
/* include_once 'library/EmailMarketing.php';
include_once 'application/simple-email/index.php'; */
session_start();
include ('include/header.php');


/* $obj= new SimpleEmail();
$obj->abc(); */
?>
<div style="width:1000px;margin:auto;padding:10px;">
<h2>Send Mail From Here</h2>
<h3 style="color:green">
<?php
if(isset($_SESSION['msg'])) echo $_SESSION['msg'];

?></h3>
<form method="post" action="library/simpleMail.php">
<table>
<tr><td>To</td><td><input type="text" name="to"></td></tr>
<tr><td>From</td><td><input type="text" name="from"></td></tr>
<tr><td>Subject</td><td><input type="text" name="subject"></td></tr>
<tr><td valign="top">Message</td><td><textarea rows="10" cols="50" name="message"></textarea></td></tr>
<tr><td><input type="submit" name="send" value="Send">
</table>
</form>
</div>
<?php
include 'include/footer.php';

sleep(3);
unset($_SESSION['msg']);





libray/simpleEmail.php




<?php
session_start();
//echo "Hello";exit;
if($_POST['send'])

{

$to = $_POST['to'];

$from = $_POST['from'];

$subject = $_POST['subject'];

$msg = $_POST['message'];   

//$mail = "aayijaaij@gmail.com";
//$to="mantu.kumar@samparkweb.com";
//$subject="Registration Confirmation";



    $data= "<table>   
    <tr><td>$msg</td></tr>
    </table>";

    $headers = "MIME-Version: 1.0" . "\r\n";

    $headers .= "Content-type: text/html; charset=iso-8859-1 ". "\r\n";

    $headers .= "Suject:$subject" . "\r\n";
   
    $headers .= "From:$from" . "\r\n";

    $data=mail($to,$subject,$data,$headers);

 if(isset($data))

 {
     //echo "Data Send Sucessfully";
     $_SESSION['msg']="Mail Sended Successfully !";
     //header('Location:http://www.diversifiedseo.com/email-marketing/application/simple-email/test.php');
     header('Location:http://www.diversifiedseo.com/email-marketing/simpleEmail.php');
 }
}
else
{
   
    header('Location:delhibid.com');
}

?>

No comments:

Post a Comment