kat32 Posted December 18, 2009 Share Posted December 18, 2009 <?php session_start(); require 'common.php'; ob_start(); $member_logged_in=$_SESSION['member_logged_in']; if( isset($_POST['send']) && $_POST['sub'] ){ $fullname = $_POST['fullname']; $email = $_POST['email']; $subject = $_POST['sub']; $body=$_POST['body']; for ($i=0; $i<count($email); $i++) { if($_POST['email'][$i]!=""){ $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $sent=mail($email[$i], $subject[$i], $body[$i], $headers); if($sent) echo 'Message sent'; } } } ?> <form method="post"> <table> <tr><td>Full Name</td><td>Please Check</td><td>Subject</td></tr> <?php // $q = mysql_query("SELECT * FROM mailinglists") or die(mysql_error()); while($row = mysql_fetch_array($q)){ $fullname=$row['fullname']; $email=$row['email'];?> <tr> <td><?php echo $fullname; echo '<input type="hidden" value="'.$fullname.'" name="fullname[]" />';?></td> <td><input type="checkbox" name="email[]" value="<?php echo $email; ?>" /></td> <td><select name="sub[]"> <?php $q2 = mysql_query("SELECT * FROM composemails") or die(mysql_error()); while($row = mysql_fetch_array($q2)){ $subject=$row['subject']; echo '<option value="'.$subject.'">'.$subject.'</option>'; } ?> </select> </td> <?php $q3 = mysql_query("SELECT * FROM composemails") or die(mysql_error()); while($row = mysql_fetch_array($q3)){ $body=$row['body']; echo '<input type="hidden" value="'.$body.'" name="body[]" />'; } ?> </tr><?php } ?> <tr><td><input type="submit" value="Send Email" name="send"/></td></tr> </table> </form> I have inserted names and email addresses in the table mailinglists. I have inserted also the subject and body in the table composemails, so that users will need to select subject for every person in the mailing list. I check all the checkbox then send and it worked fine. The subject is blank when I send an email to the second or last name in the mailing list. When I open the email of the second or last person in the mailing list, "[No Subject]" appeared. I really need your help. Link to comment https://forums.phpfreaks.com/topic/185562-problem-sending-mails-no-subject/ Share on other sites More sharing options...
teynon Posted December 18, 2009 Share Posted December 18, 2009 You need to output the arrays as your sending it to confirm that those values are not in fact empty. Do a print_r($subject); Link to comment https://forums.phpfreaks.com/topic/185562-problem-sending-mails-no-subject/#findComment-979720 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.