view newsletter/newsletter_110120.php @ 15:385ddd7c4b55 testing

use test_db.php to get mysqld_test instance
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Sun, 19 Feb 2017 16:17:53 +0000
parents 077b0a0a3e6d
children
line wrap: on
line source

<?PHP

include "../../../private/db_test.php"; 

$myFile = "newsletterOutput";
$fh = fopen($myFile, 'w') or die("can't open file");

for ( $counter = 0; $counter <= 4000; $counter += 50) {

$upper = $counter+51;

	$query1 = "select distinct Email from user u, userpref up where u.UserID = up.UserID and ReceiveEmail = 1 and u.UserID > $counter and u.UserID < $upper";
	//echo $query1;
	
	$data = mysqli_query($link, $query1);

	fwrite($fh, date("d/m/y : H:i:s", time()));
	fwrite($fh, " Sent mail to:\n");
	
	while($line = mysqli_fetch_assoc($data))
	{
		$email=$line["Email"];
		
		if (substr($email,0,1) != "@")
		{
		
		$message = "<html>
<head>
<title>YourNextRead Newsletter</title>
</head>
<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"#232323\" align=\"center\">
<tbody><tr><td>
<table width=\"600\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"#ffffff\" align=\"center\">

	<tbody>
	<tr></tr>
	  <tr>
		<td bgcolor=\"#232323\" width=\"15\"></td>
		<td bgcolor=\"#232323\">
			<center><font face=\"verdana, sans-serif, arial\" color=\"#ffffff\" style=\"font-size:10px;\" size=\"1\">
			Discover and share with YourNextRead. Having trouble viewing this email? See it <a rel=\"nofollow\" target=\"_blank\" href=\"http://www.yournextread.com/newsletter/jan2011.html\" style=\"color:#ffffff;\">online<font face=\"verdana, sans-serif, arial\" color=\"#ffffff\" style=\"font-size:10px;\" size=\"1\"></font></a>. To help stop our emails being seen as spam, please add <strong><span style=\"border-bottom-style: dashed; border-bottom-width: 1px; border-bottom-color: rgb(0, 102, 204); cursor: pointer; \">newsletter@YourNextRead.com</span></strong> to your address book.
			<br><br>
			</font></center>
		</td>
		<td bgcolor=\"#232323\" width=\"15\"></td>
	  </tr>
	
	<tr>
		<td colspan=\"3\" bgcolor=\"#232323\" ><A HREF=\"http://www.yournextread.com/\"><img src=\"http://www.yournextread.com/images/read/top_email.jpg\" style=\"border:0px;display:block;\" width=\"600\" height=\"63\" alt=\"\"></a></td>
	</tr>

	<tr>
		<td bgcolor=\"#ffffff\" colspan=\"2\">
		<table width=\"600\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\" bgcolor=\"#ffffff\">
			<tbody>
			<tr>
				<td bgcolor=\"#594f43\"> <font face=\"verdana, sans-serif, arial\" color=\"#ffffff\" style=\"font-size:12px;\">
				20th January 2011
				</font> </td>
			</tr>
			<tr>
				<td bgcolor=\"#f2b234\"> 
					<font face=\"verdana, sans-serif, arial\" color=\"#232323\" style=\"font-size:20px; font-weight:bold;\"> 
						Take YourNextRead with you everywhere
					</font>
					<br>
					<font face=\"verdana, sans-serif, arial\" color=\"#232323\" style=\"font-size:12px; font-weight:bold;\">
						New Mobile Version of YourNextRead.com 
					</font>
				</td>
			</tr>
			</tbody>
		</table>
		</td>
	</tr>
	<tr></tr>
	<tr>
		<td bgcolor=\"#ffffff\" colspan=\"3\">
		<table width=\"570\" cellpadding=\"10\" cellspacing=\"0\" border=\"0\" bgcolor=\"#ffffff\">
			<tbody>
			<tr>
				<td>
					<font face=\"verdana, sans-serif, arial\" color=\"#0000000\" style=\"font-size:12px;\"></font>
					<p style=\"font-family:verdana, sans-serif, arial;font-weight:100;color:#0000000;font-size:13px;line-height:14px;\">
					Happy Belated New Year!!</p> 
					<p style=\"font-family:verdana, sans-serif, arial;font-weight:100;color:#0000000;font-size:13px;line-height:14px;\">We have been working hard to make YourNextRead easier to use wherever you are and we now have a great new mobile website online! Try it out now on your mobile device by visiting us at <a href=\"http://www.yournextread.com/\">YourNextRead.com</a>. 
					</p>
					<p style=\"font-family:verdana, sans-serif, arial;font-weight:100;color:#0000000;font-size:13px;line-height:14px;\">With the mobile version you can still recommend books, view Goodreads and Amazon reviews and sign-in to see all of your saved lists. Please send us any <a href=\"mailto:feedback@yournextread.com\">feedback</a> you have, so we can keep improving YourNextRead for you.</p>
					<div style=\"border-bottom:solid;border-bottom-width:2px;border-bottom-color:#f2b234;height:1px;width:570px;margin-top:8px;margin-bottom:10px;\"></div>
					</p><p style=\"font-family:verdana, sans-serif, arial;font-weight:100;color:#0000000;font-size:13px;line-height:14px;\">
					The YourNextRead team wish you all the best for 2011.
					</p>
					<p style=\"font-family:verdana, sans-serif, arial;font-weight:100;color:#0000000;font-size:13px;line-height:14px;\">
					YourNextRead
					</p>
					
					<p><a href=\"http://www.facebook.com/YourNextRead/\"><img src=\"http://www.buttonshut.com/Facebook-Buttons/Facebook-Buttons-42-32-.gif\" border=\"0\"/></a>  <a href=\"http://www.twitter.com/YourNextRead\" ><img src=\"http://www.twitterbuttons.com/upload/badges/02bb9f0627follow-us-1.gif\" border=\"0\"/></a>
					 <br/></p>	
					<div style=\"border-bottom:solid;border-bottom-width:2px;border-bottom-color:#f2b234;height:1px;width:570px;margin-top:8px;margin-bottom:10px;\"></div>
					
				</td>
			</tr>
			</tbody>
		</table>
		</td>
	</tr>

	<tr>
		<td colspan=\"3\" bgcolor=\"#232323\"><br>
			<font face=\"arial, verdana, sans-serif\" color=\"#ffffff\" size=\"1\" style=\"font-size:10px;\">
			Terms and Conditions 
			<br><br>
			This is a genuine email from <span style=\"border-bottom-style: dashed; border-bottom-width: 1px; border-bottom-color: rgb(0, 102, 204); cursor: pointer; \">YourNextRead</span>. However, if you receive an email which you are concerned does not legitimately originate from us, you can report it via <a rel=\"nofollow\" target=\"_blank\" href=\"mailto:feedback@yournextread.com\" style=\"color:#ffffff;\"><span class=\"yshortcuts\">emailing us</span></a> before deleting it.
			<br><br>
			You have received this email because you have opted in to receive news, updates and offers from YourNextRead
			<br><br>
			You can  <a rel=\"nofollow\" target=\"_blank\" href=\"http://www.yournextread.com/user/unsubscribe.php?email=$email\" style=\"color:#ffffff;\"><span>unsubscribe here</span></a>, however as the majority of our communications are via email, you'll be missing out.
			<br>
			</font>			
		</td>
	</tr>

</tbody></table>


</td></tr></tbody></table></html>";

			$header="from: YourNextRead <newsletter@yournextread.com>\nContent-Type: text/html; charset=iso-8859-1";
			$to=$email;
			$subject="Take YourNextRead with you everywhere";
			$sentmail = mail($to,$subject,$message,$header);
			fwrite($fh, "$email\n");
		}
		
	}
	
	sleep(60);
}
fwrite($fh, "COMPLETE");
fclose($fh);