Link to home
Start Free TrialLog in
Avatar of Desire2change
Desire2change

asked on

phpmailer add attachment

I am sending mails using phpmailer, it sends mail and sends attachment but just sends one
no error.
$to=$row['fldemail'];
			$mail = new phpmailer();
			$mail->IsHTML(true);
			$mail->Subject = $_POST['subject'];
			$mail->Body    =$_POST['message'];
			$mail->From = "admin@xyz.com";
			$mail->FromName="xyz";
			$mail->AddAddress($to);
			if($_FILES['file1']['name']!='')
			{
				if(!$mail->AddAttachment($_FILES['file1']['tmp_name'], $_FILES['file1']['name']))
				{
					echo $mail->ErrorInfo;
   					die('unable to add attachment no.1 => '.$_FILES['file1']['name']);
				}
			}
 
 
 
			if($_FILES['file2']['name']!='')
			{
				if(!$mail->AddAttachment($_FILES['file2']['tmp_name'], $_FILES['file2']['name']))
				{
					echo $mail->ErrorInfo;
   					die('unable to add attachment no.2 => '.$_FILES['file2']['name']);
				}
			}
 
			if($_FILES['file3']['name']!='')
			{
				if(!$mail->AddAttachment($_FILES['file3']['tmp_name'], $_FILES['file3']['name']))
				{
					echo $mail->ErrorInfo;
   					die('unable to add attachment no.3 => '.$_FILES['file3']['name']);
				}
			}
 
			if($_FILES['file4']['name']!='')
			{
				if(!$mail->AddAttachment($_FILES['file4']['tmp_name'], $_FILES['file4']['name']))
				{
					echo $mail->ErrorInfo;
   					die('unable to add attachment no.4 => '.$_FILES['file4']['name']);
				}
			}
 
			if($_FILES['file5']['name']!='')
			{
				if(!$mail->AddAttachment($_FILES['file5']['tmp_name'], $_FILES['file5']['name']))
				{
					echo $mail->ErrorInfo;
   					die('unable to add attachment no.5 => '.$_FILES['file5']['name']);
				}
			}
 
			if($_FILES['file6']['name']!='')
			{
				if(!$mail->AddAttachment($_FILES['file6']['tmp_name'], $_FILES['file6']['name']))
				{
					echo $mail->ErrorInfo;
   					die('unable to add attachment no.6 => '.$_FILES['file6']['name']);
				}
			}
 
 
 
			$mail->AltBody ="Your mail is not supporting html format";
			$mail->IsMail();
			if($mail->Send())
				$err='Mail sent successfully!';
			else
				$err='Mail cud not b sent!';

Open in new window

Avatar of agdub
agdub
Flag of United States of America image

could you add the form that is being sent to this file?
Avatar of Desire2change
Desire2change

ASKER

<form action="sendmail1.php?frm=<?php echo $_GET['frm']; ?>&sessid=<?php echo $_GET['sessid']; ?>" method="post" enctype="multipart/form-data" name="myfrm" class="frm">
                    <br>




                    <table width="80%" border="0" align="center" cellpadding="6" cellspacing="4">
  <tr>
    <td align="left" valign="middle"><span class="style5">
      <label>Select Category To Send Mails :</label>
    </span></td>
    <td><span class="style5">
      <select name="category" id="category">
        <option value="1" selected>Blue Streak</option>
        <option value="2">BWD</option>
        <option value="3">Four Seasons</option>
        <option value="4">Cooling Depot</option>
      </select>
(approved members of selected category will get the files) </span></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><span class="style5">Subject:</span></td>
    <td><input name="subject" type="text" id="subject" size="50"></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><span class="style5">Message:</span></td>
    <td><span class="style5">
      <textarea name="message" cols="50" rows="5" id="message"></textarea>
    </span></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><span class="style5">Attachment#1:</span></td>
    <td><input name="file1" type="file" id="file1" size="50"></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><span class="style5">Attachment#2:</span></td>
    <td><input name="file2" type="file" size="50" id="file2"></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><span class="style5">Attachment#3:</span></td>
    <td><input name="file3" type="file" size="50" id="file3"></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><span class="style5">Attachment#4:</span></td>
    <td><input name="file4" type="file" size="50" id="file4"></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><span class="style5">Attachment#5:</span></td>
    <td><input name="file5" type="file" size="50" id="file5"></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><span class="style5">Attachment#6:</span></td>
    <td><input name="file6" type="file" size="50" id="file6"></td>
  </tr>
</table>

                      






<!--End container-->

<!--start footer-->


<input type="image" value="" src="images/comment/submit1.jpg" srcover="images/comment/submit.jpg"
        border="0" class="up_pro" />
    </form>
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I had already printed the $_FILES and checkd, after checking all , I have posted this question
The $_FILES have all file names , all 6 files , if I upload 6 files.
So the form is submitted correctly.....
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial