mail using php

03:15:00 0 Comments


Mail using php


....Easily create a php email program.Hi in this I will show you how to create a bulk email using php using this code you can easily create a bulk email service. You can send your customers emails if their emails are stored in the database this is really easy.It just uses a for loop and the php mail code and some html files.You will even have a very nice html form to use and you will even have the email sent on a nice template.

See the project files for download here below.

https://drive.google.com/open?id=0B8Uhxk8DKNMqR2VNM0w0M09hOW8&authuser=0


Below is the screen short.

Here are the important files..

1.bulkmail.html


<!doctype html>
<html>
<head>

<!-- Place inside the <head> of your HTML -->
<script type="text/javascript" src="js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
    selector: "textarea"
 });
</script>


<meta charset="utf-8">
<title>Mail Send Template</title>
</head>

<body>
<form action="mailalerts.php">
  <p>Email Subject :<br>
    <input type="text" name="subject" id="subject">
  </p>
  <p>Topic :<br>
    <input type="text" name="topic" id="topic">
  </p>
  <p>Topic header:<br>
    <input type="text" name="topicheader" id="topicheader">
    <br>
    topic data:<br>
    
    <textarea name="data" id="data"></textarea>
       for link example   &lt;a href=&quot;http://worldmartindia.blogspot.in/2014/11/3-simple-growth-hacks-for-ecommerce.html&quot;&gt;this is the blog &lt;/a&gt;</p>
  <p>,use &lt;br&gt; for next line<br>
    <input type="radio"   name="type" value="all" checked>all
    <br>
    <input type="radio"  name="type" value="free">free
    <br>
    <input type="radio"  name="type" value="paid">paid
    
    <input type="submit" value="Submit">
  </p>
</form>
</body>
</html>



2.Mailalerts.php



<?php

include "storescripts/connect_to_mysql.php"; 


$strSQL = "SELECT * FROM ps_employee";
$rs = mysql_query($strSQL);

$subject=$_GET['subject'];
$topic=$_GET['topic'];
$topicheader=$_GET['topicheader'];
$type= $_GET['type'];
$data=$_GET['data'];
$type= $_GET['type'];





echo $topic;
echo $data;
echo $type;




while($row = mysql_fetch_array($rs)) {

  
  
  
  // echo "<tr>"; 
//echo "<td>" .$enddate = $row['enddate'];
$email = $row['email'];
$shopname = $row['shopname'];
$firstname = $row['firstname'];

$originalcost = $row['originalcost'];


//echo "<h1>" .$originalcost."</h1>";



$datetime1 = date('Y-m-j');

//echo $datetime1. "</td></tr></br>";

$interval = date_diff(date_create($datetime1), date_create($enddate));

//echo $interval->format('%R%a');

$daysleft=$interval->format('%R%a');



if($type=='all' ){














$headers = 'From: freeonlinestore<support@worldmart.in>' . "\r\n" .
   'Reply-To: support@worldmart.in' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();
//$replyto="";
//$headers .= 'From: ' . $from . "\r\n";
//$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
//$headers .= "BCC: support@worldmart.inple.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";






$msg ="<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd'>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' />
<title>Message from {shop_name}</title>


<style> @media only screen and (max-width: 300px){ 
body {
width:218px !important;
margin:auto !important;
}
.table {width:195px !important;margin:auto !important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto !important;display: block !important;}
span.title{font-size:20px !important;line-height: 23px !important}
span.subtitle{font-size: 14px !important;line-height: 18px !important;padding-top:10px !important;display:block !important;}
td.box p{font-size: 12px !important;font-weight: bold !important;}
.table-recap table, .table-recap thead, .table-recap tbody, .table-recap th, .table-recap td, .table-recap tr { 
display: block !important; 
}
.table-recap{width: 200px!important;}
.table-recap tr td, .conf_body td{text-align:center !important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
@media only screen and (min-width: 301px) and (max-width: 500px) { 
body {width:308px!important;margin:auto!important;}
.table {width:285px!important;margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
.table-recap table, .table-recap thead, .table-recap tbody, .table-recap th, .table-recap td, .table-recap tr { 
display: block !important; 
}
.table-recap{width: 293px !important;}
.table-recap tr td, .conf_body td{text-align:center !important;}

}
@media only screen and (min-width: 501px) and (max-width: 768px) {
body {width:478px!important;margin:auto!important;}
.table {width:450px!important;margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
}
@media only screen and (max-device-width: 480px) { 
body {width:308px!important;margin:auto!important;}
.table {width:285px;margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}

.table-recap{width: 285px!important;}
.table-recap tr td, .conf_body td{text-align:center!important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
</style>

</head>
<body style='-webkit-text-size-adjust: none; background-color: #fff; width: 650px; font-family: Open-sans, sans-serif; color: #777; font-size: 13px; line-height: 18px; margin: auto'>
<table class='table table-mail' style='width:100%;margin-top:10px;-moz-box-shadow:0 0 5px #afafaf;-webkit-box-shadow:0 0 5px #afafaf;-o-box-shadow:0 0 5px #afafaf;box-shadow:0 0 5px #afafaf;filter:progid:DXImageTransform.Microsoft.Shadow(color=#afafaf,Direction=134,Strength=5)'>
<tr>
<td class='space' style='width:20px;padding:7px 0'>&nbsp;</td>
<td align='center' style='padding:7px 0'>
 <table class='table' bgcolor='#ffffff' style='width:100%'>
<tr>
<td align='center' class='logo' style='border-bottom:4px solid #333333;padding:7px 0'>&nbsp;</td>
</tr>

<tr>
<td align='center' class='titleblock' style='padding:7px 0'>
<font size='2' face='Open-sans, sans-serif' color='#555454'><br/>
</font>
<h2 id='DiscoveringtheAdministrationArea-DiscoveringtheAdministrationArea'>$topic</h2></td>
</tr>
<tr>
<td class='space_footer' style='padding:0!important'><p>&nbsp;</p>
 <p>&nbsp;</p></td>
</tr>
<tr>
  <td class='space_footer' style='padding:0!important'>&nbsp;</td>
</tr>
<tr>
<td class='box' style='border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0'>
<table class='table' style='width:100%'>
<tr>
<td width='10' style='padding:7px 0'>&nbsp;</td>
<td style='padding:7px 0'><h2 id='DiscoveringtheAdministrationArea-Overviewofthemaininterface'>$topicheader</h2>  <p>$data</p>
</td>
<td width='10' style='padding:7px 0'>&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class='space_footer' style='padding:0!important'>&nbsp;</td>
</tr><td class='space_footer' style='padding:0!important'>&nbsp;</td>



<tr>
<td class='space_footer' style='padding:0!important'>&nbsp;</td>
</tr>
                        
                        
                        
                        
                        
<tr>
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
<td class='footer' style='border-top:4px solid #333333;padding:7px 0'>&nbsp;</td>
</tr>
</table>
</td>
<td class='space' style='width:20px;padding:7px 0'>&nbsp;</td>
</tr>
</table>
</body>
</html>";



//mail("support@worldmart.in",$subject,$msg,$headers);
//mail("joeljfernandes@yahoo.com",$subject,$msg,$headers);
//mail("webdesign@worldmart.in",$subject,$msg,$headers);
mail($email,$subject,$msg,$headers);





}elseif($type=='free' && $originalcost == 0){

echo "hi free";


$headers = 'From: freeonlinestore<support@worldmart.in>' . "\r\n" .
   'Reply-To: support@worldmart.in' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();
//$replyto="";
//$headers .= 'From: ' . $from . "\r\n";
//$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
//$headers .= "BCC: support@worldmart.inple.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";






$msg ="<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd'>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' />
<title>Message from {shop_name}</title>


<style> @media only screen and (max-width: 300px){ 
body {
width:218px !important;
margin:auto !important;
}
.table {width:195px !important;margin:auto !important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto !important;display: block !important;}
span.title{font-size:20px !important;line-height: 23px !important}
span.subtitle{font-size: 14px !important;line-height: 18px !important;padding-top:10px !important;display:block !important;}
td.box p{font-size: 12px !important;font-weight: bold !important;}
.table-recap table, .table-recap thead, .table-recap tbody, .table-recap th, .table-recap td, .table-recap tr { 
display: block !important; 
}
.table-recap{width: 200px!important;}
.table-recap tr td, .conf_body td{text-align:center !important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
@media only screen and (min-width: 301px) and (max-width: 500px) { 
body {width:308px!important;margin:auto!important;}
.table {width:285px!important;margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
.table-recap table, .table-recap thead, .table-recap tbody, .table-recap th, .table-recap td, .table-recap tr { 
display: block !important; 
}
.table-recap{width: 293px !important;}
.table-recap tr td, .conf_body td{text-align:center !important;}

}
@media only screen and (min-width: 501px) and (max-width: 768px) {
body {width:478px!important;margin:auto!important;}
.table {width:450px!important;margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
}
@media only screen and (max-device-width: 480px) { 
body {width:308px!important;margin:auto!important;}
.table {width:285px;margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}

.table-recap{width: 285px!important;}
.table-recap tr td, .conf_body td{text-align:center!important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
</style>

</head>
<body style='-webkit-text-size-adjust: none; background-color: #fff; width: 650px; font-family: Open-sans, sans-serif; color: #777; font-size: 13px; line-height: 18px; margin: auto'>
<table class='table table-mail' style='width:100%;margin-top:10px;-moz-box-shadow:0 0 5px #afafaf;-webkit-box-shadow:0 0 5px #afafaf;-o-box-shadow:0 0 5px #afafaf;box-shadow:0 0 5px #afafaf;filter:progid:DXImageTransform.Microsoft.Shadow(color=#afafaf,Direction=134,Strength=5)'>
<tr>
<td class='space' style='width:20px;padding:7px 0'>&nbsp;</td>
<td align='center' style='padding:7px 0'>
 <table class='table' bgcolor='#ffffff' style='width:100%'>
<tr>
<td align='center' class='logo' style='border-bottom:4px solid #333333;padding:7px 0'>&nbsp;</td>
</tr>

<tr>
<td align='center' class='titleblock' style='padding:7px 0'>
<font size='2' face='Open-sans, sans-serif' color='#555454'><br/>
</font>
<h2 id='DiscoveringtheAdministrationArea-DiscoveringtheAdministrationArea'>$topic</h2></td>
</tr>
<tr>
<td class='space_footer' style='padding:0!important'><p>&nbsp;</p>
 <p>&nbsp;</p></td>
</tr>
<tr>
  <td class='space_footer' style='padding:0!important'>&nbsp;</td>
</tr>
<tr>
<td class='box' style='border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0'>
<table class='table' style='width:100%'>
<tr>
<td width='10' style='padding:7px 0'>&nbsp;</td>
<td style='padding:7px 0'><h2 id='DiscoveringtheAdministrationArea-Overviewofthemaininterface'>$topicheader</h2>  <p>$data</p>
</td>
<td width='10' style='padding:7px 0'>&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class='space_footer' style='padding:0!important'>&nbsp;</td>
</tr><td class='space_footer' style='padding:0!important'>&nbsp;</td>



<tr>
<td class='space_footer' style='padding:0!important'>&nbsp;</td>
</tr>
                        
                        
                        
                        
                        
<tr>
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
<td class='footer' style='border-top:4px solid #333333;padding:7px 0'>&nbsp;</td>
</tr>
</table>
</td>
<td class='space' style='width:20px;padding:7px 0'>&nbsp;</td>
</tr>
</table>
</body>
</html>";



//mail("support@worldmart.in",$subject,$msg,$headers);
//mail("joeljfernandes@yahoo.com",$subject,$msg,$headers);
//mail("webdesign@worldmart.in",$subject,$msg,$headers);
mail($email,$subject,$msg,$headers);





}elseif($type=='paid' && $originalcost > 0){

echo"hi only paid";

$headers = 'From: freeonlinestore<support@worldmart.in>' . "\r\n" .
   'Reply-To: support@worldmart.in' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();
//$replyto="";
//$headers .= 'From: ' . $from . "\r\n";
//$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
//$headers .= "BCC: support@worldmart.inple.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";






$msg ="<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd'>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' />
<title>Message from {shop_name}</title>


<style> @media only screen and (max-width: 300px){ 
body {
width:218px !important;
margin:auto !important;
}
.table {width:195px !important;margin:auto !important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto !important;display: block !important;}
span.title{font-size:20px !important;line-height: 23px !important}
span.subtitle{font-size: 14px !important;line-height: 18px !important;padding-top:10px !important;display:block !important;}
td.box p{font-size: 12px !important;font-weight: bold !important;}
.table-recap table, .table-recap thead, .table-recap tbody, .table-recap th, .table-recap td, .table-recap tr { 
display: block !important; 
}
.table-recap{width: 200px!important;}
.table-recap tr td, .conf_body td{text-align:center !important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
@media only screen and (min-width: 301px) and (max-width: 500px) { 
body {width:308px!important;margin:auto!important;}
.table {width:285px!important;margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
.table-recap table, .table-recap thead, .table-recap tbody, .table-recap th, .table-recap td, .table-recap tr { 
display: block !important; 
}
.table-recap{width: 293px !important;}
.table-recap tr td, .conf_body td{text-align:center !important;}

}
@media only screen and (min-width: 501px) and (max-width: 768px) {
body {width:478px!important;margin:auto!important;}
.table {width:450px!important;margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
}
@media only screen and (max-device-width: 480px) { 
body {width:308px!important;margin:auto!important;}
.table {width:285px;margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}

.table-recap{width: 285px!important;}
.table-recap tr td, .conf_body td{text-align:center!important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
</style>

</head>
<body style='-webkit-text-size-adjust: none; background-color: #fff; width: 650px; font-family: Open-sans, sans-serif; color: #777; font-size: 13px; line-height: 18px; margin: auto'>
<table class='table table-mail' style='width:100%;margin-top:10px;-moz-box-shadow:0 0 5px #afafaf;-webkit-box-shadow:0 0 5px #afafaf;-o-box-shadow:0 0 5px #afafaf;box-shadow:0 0 5px #afafaf;filter:progid:DXImageTransform.Microsoft.Shadow(color=#afafaf,Direction=134,Strength=5)'>
<tr>
<td class='space' style='width:20px;padding:7px 0'>&nbsp;</td>
<td align='center' style='padding:7px 0'>
 <table class='table' bgcolor='#ffffff' style='width:100%'>
<tr>
<td align='center' class='logo' style='border-bottom:4px solid #333333;padding:7px 0'>&nbsp;</td>
</tr>

<tr>
<td align='center' class='titleblock' style='padding:7px 0'>
<font size='2' face='Open-sans, sans-serif' color='#555454'><br/>
</font>
<h2 id='DiscoveringtheAdministrationArea-DiscoveringtheAdministrationArea'>$topic</h2></td>
</tr>
<tr>
<td class='space_footer' style='padding:0!important'><p>&nbsp;</p>
 <p>&nbsp;</p></td>
</tr>
<tr>
  <td class='space_footer' style='padding:0!important'>&nbsp;</td>
</tr>
<tr>
<td class='box' style='border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0'>
<table class='table' style='width:100%'>
<tr>
<td width='10' style='padding:7px 0'>&nbsp;</td>
<td style='padding:7px 0'><h2 id='DiscoveringtheAdministrationArea-Overviewofthemaininterface'>$topicheader</h2>  <p>$data</p>
</td>
<td width='10' style='padding:7px 0'>&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class='space_footer' style='padding:0!important'>&nbsp;</td>
</tr><td class='space_footer' style='padding:0!important'>&nbsp;</td>



<tr>
<td class='space_footer' style='padding:0!important'>&nbsp;</td>
</tr>
                        
                        
                        
                        
                        
<tr>
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
<td class='footer' style='border-top:4px solid #333333;padding:7px 0'>&nbsp;</td>
</tr>
</table>
</td>
<td class='space' style='width:20px;padding:7px 0'>&nbsp;</td>
</tr>
</table>
</body>
</html>";



//mail("support@worldmart.in",$subject,$msg,$headers);
//mail("joeljfernandes@yahoo.com",$subject,$msg,$headers);
//mail("webdesign@worldmart.in",$subject,$msg,$headers);
mail($email,$subject,$msg,$headers);






}




}


?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
</body>

</html>

3.Enter your database connection to your storescripts folder config file.

Joel

Joel Fernandes,I am a Very Smart,Innovative Creative and One of the Best Webdevelopers.I am an expert in Webdevelopment.My other interest include Cars and Vehicles.My desire is to be the best and serve you with the best information I have .I will always share all my tips and tricks on this website and provide you with the best themes so that your life may be simpler.Keep visiting www.joelwebsites.com for the best website related ,tips and tricks and news.Meet me on FaceBook

0 comments: