pazafuera Posted July 25, 2008 Share Posted July 25, 2008 Hey everybody...I've got a head scratcher that is driving me nuts. The basic operation of this page: 1. Pull email address from mailing list table 2. Send email with to each email address (the email contains database driven content) The email is sending, but with some issues. The first email address is getting the job alerts for all users in the table...for example: Joe gets: Joe's alerts | Tim's alerts | Mike's alerts Tim gets: Tim's alerts | Mike's alerts Mike gets: Mike's alerts Here's the code: $query = mysql_query("SELECT * FROM `alert_jobalerts2`"); if(!$query) die(mysql_error()); $date = mktime(0,0,0,date("m"),date("d"),date("Y")); while($code = mysql_fetch_object($query)) { $to = "$code->UserEmail"; $subject = "Job Alerts"; $headers = "From: [email protected]\r\n"; $headers .= "Reply-To: [email protected]\r\n"; $headers .= "Return-Path: [email protected]\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message .= "<table border='0' width='675'>"; $message .= "<tr>"; $message .= "<td>"; $message .= "<img border='0' src='http://www.picture.com/picture.jpg' width='675' height='86'></td>"; $message .= "</tr>"; $message .= "<tr>"; $message .= "<td>"; $message .= "<table border='0' width='100%' cellspacing='0' cellpadding='3'>"; $message .= "<tr>"; $message .= "<td><b><font size='4' color='#8D2C41'>Your Job Alerts for ".date('m/d/Y')."</font></b></td>"; $message .= "<td width='109'>"; $message .= "<p align='right'>"; $message .= "<img border='0' src='http://www.picture.com/picture.jpg' width='96' height='60'></td>"; $message .= "</tr>"; $message .= "</table>"; $message .= "</td>"; $message .= "</tr>"; $message .= "<tr>"; $message .= "<td>$code->UserName,<p>Here are today's featured Jobs:<br><br></td>"; $message .= "</tr>"; $message .= "<tr>"; $message .= "<td>"; $message .= "<table border='0' width='100%' cellspacing='2' cellpadding='5'>"; $message .= "<tr>"; $message .= "<td width='50%' valign='top'>"; $message .= "<table border='0' width='100%' cellspacing='2' cellpadding='5' bordercolor='#ADC9E2' style='border-left-width: 0px; border-right-width: 0px'>"; $message .= "<tr>"; $message .= "<td bgcolor='#E2ECF5' style='border-style: solid; border-width: 1px'>"; $message .= "<b>Category 1</b></td>"; $message .= "</tr>"; $message .= "<tr>"; $message .= "<td style='border-left-style: solid; border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-bottom-style: solid; border-bottom-width: 1px'>"; $message .= "<table border='0' width='100%' cellspacing='2' cellpadding='5'>"; $Category1 = mysql_query("SELECT * FROM `jos_jobfeeds_featured3` WHERE jobsegment = 'Category1' AND featureddate = '".date("Y/m/d", $date)."';"); if(!$Category1) die(mysql_error()); while($code = mysql_fetch_object($Category1)) { $message .= "<tr>"; $message .= "<td><a href='http://www.mydomain.com/index.php?option=com_content&task=view&id=386&Itemid=276&jobid=$code->jobid'><b>$code->jobtitle</b></a><br><b>$code->employer</b> | $code->jobcity, $code->jobstate</a></td>"; $message .= "</tr>"; } $message .= "</table>"; $message .= "</td>"; $message .= "</tr>"; $message .= "<tr>"; $message .= "<td> </td>"; $message .= "</tr>"; $message .= "</table>"; if ( mail($to,$subject,$message,$headers) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } } I have several other email scripts just like this that work properly, but this one has this particular issue. I hope my explaination of the problem wasn't too confusing. Any ideas? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/116635-email-script-issues/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.