Newsletter subscription in php - Mostlikers

05 September, 2013

Newsletter subscription in php

This post I explain about news letter subscription. This code related on  feed burner concept, Once user register they mail id in server when admin posted on any message. its send superscribe user.  


Previously i posted on how to subscribe the users register our email and store to the database  so now continue on how admin post message send through the all subscriber.

PHP

Group mails store on array $mails its send throghu the message on all user if you want send database stored mails direct fetch and store $mails.

<?php
if(isset($_POST['submit']))
{
$msg=$_POST['post-message'];
$subject = "Mostlikers group mail";
$mails = array('sample@mail.com', 'sample@mail.com', 'sample@mail.com');
$to= implode(",", $mails);
$message = '
<html>
<body>
<table width="592" border="0" cellpadding="0" cellspacing="0">
<td width="592" valign="top"><p>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikhgNZmmufhc_CGbvWHxBcxpWVqo1Bd4FJFibJih0Sl1dO1MtTw8WLYaavIxxdOX3XLJqIIBa4Gq7SEM-QdSNNMmOxIssjzZJFEmIqa5yOAMED9apwgyInVR9m9C37be54R3kZG5gF_BfH/s1600/logos.png" ></p>
<font face="Verdana, Arial, Helvetica, sans-serif" style="font-size: 11px">
<b>Dear Subscripers,</b><p><br>
'
.$msg.'
<p><br>
watch more in tips mostlikers</font>
</td>
</tr>
</table>
</body>
</html>
'
;
$headers = "MIME-Version: 1.0\r\n";
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers = "From: Mostlikers\r\n";
if(mail($to, $subject, $message, $headers))
{
echo "check your mail now";
}
else
{
echo "Failed to send the mail";
}
}
?>

HTML & CSS

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>News Letter</title>
<style type="text/css">
.Base
{
width:600px;
height:600px;
border:dashed 1px #00CCFF;
margin:0 auto;
}
.box
{
width:400px;
height:30px;
text-align:center;
font-size:24px;
box-shadow: inset 0 1px 15px rgba(0,0,0,0.1);
margin:0 auto;

}
.clear
{
margin-top:10px;
}
.message
{
width:300px;
height:0 auto;
margin:0 auto;
}
</style>
</head>
<body>
<div class="Base">
<div class="clear"></div>
<div class="message">
<form name="compose" method="post">
<label>Compose New Message on Admin</label>
<textarea cols="40" rows="10" name="post-message"></textarea>
<p align="center"><input type="submit" name="submit" value="Send message" /></p>
</form>
</div>
</div>
</body>
</html>

No comments:

Post a Comment