Need help with lists and sending HTML email in PHP
Posted: Mon Mar 26, 2012 1:11 pm
Hello All, it has been about 5 years since I have had to write anything in PHP, so forgive me. I am trying to load data from a .csv file (name, email address, restaurant name) and then run through the number of records in the file and send an individualized email to each person on the list. The emails should go out as an HTML email.
I have been playing around with this, but it isn't right:
I'm really lost and I am sure this is simple, but 5 years of not looking at this stuff made me forget a lot. And no, this isn't spam, this is a list we have been compiling for quite some time.
Thanks for any help!
I have been playing around with this, but it isn't right:
Code: Select all
<?php
$row = 1;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
//data stored in $data
echo $data['fieldname'];
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);
}
?>
<?
//change this to your email.
$to = $data0;
$from = "rmy@yinfo.com";
$subject = "Your Invitation To Appear In Food & Wine Magazine.";
//begin of HTML message
$message = <<<EOF
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
-->
</style>
</head>
<body>
<table width="620" border="0" cellspacing="3" cellpadding="2">
<tr>
<td> <p class="style1">Dear <?php $data1 ; ?>, <br />
<br />
Please scroll down to view your invitation to appear in a special restaurant feature in Food & Wine magazine being presented in the July 2012 issue. </p></td>
</tr>
<tr>
<td><div align="center"><br />
<img src="http://domain.com/mailassets/foodwine_logo.jpg" width="366" height="68" /><br />
</div></td>
</tr>
<tr>
<td> <p class="style1">The feature is entitled<strong> "The Great Restaurants of America"</strong>, and is a monthly highlight which focuses on a different city each issue. <br />
<br />
The July issue will spotlight the Greater Atlanta areas leading restaurants. Restaurants are included strictly on an invitation-only basis. Please take a moment and read the attached few pages which will give you full information on this important feature. <br />
<br />
Please feel free to call me to answer any questions you may have. Looking forward to seeing you in Food & Wine magazine. </p>
<p class="style1"> </p></td>
</tr>
<tr>
<td><p class="style1">Many Thanks,</p></td>
</tr>
<tr>
<td><img src="http://domain.com/mailassets/signature.jpg" width="210" height="102" /></td>
</tr>
<tr>
<td><p class="style1">RMY<br />
305-517- 6620<br />
<a href="mailto:rmy@yinfo.com" target="_blank">rmy@yinfo.com</a> </p></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><img src="http://domain.com/mailassets/p1.jpg" width="612" height="792" /></td>
</tr>
<tr>
<td><img src="http://domain.com/mailassets/p2.jpg" width="612" height="792" /></td>
</tr>
<tr>
<td><img src="http://domain.com/mailassets/p3.jpg" width="612" height="792" /></td>
</tr>
<tr>
<td><img src="http://domain.com/mailassets/p4.jpg" width="612" height="792" /></td>
</tr>
<tr>
<td><img src="http://domain.com/mailassets/p5.jpg" width="612" height="792" /></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
EOF;
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
//options to send to cc+bcc
//$headers .= "Cc: [email]maa@p-i-s.cXom[/email]";
//$headers .= "Bcc: [email]email@maaking.cXom[/email]";
// now lets send the email.
mail($to, $subject, $message, $headers);
echo "Message has been sent....!";
?>
Thanks for any help!