I have made an Email Form with multiple attachments ,. The code i am using is as follows: The error is when i have written the Loop for multiple attachments, and set all the code on the Submit button event, Nothing happens… Before, it. Mail is sent, with the attachments except the loop attachments
[php]<?php
(isset($_POST[‘Submit1’]))
{
include “class.phpmailer.php”;
$From = "[email protected]";
$FromName = “From Name”;
$To = "[email protected]";
$ToName = “To Name”;
$Subject = “Hello there, you will receive some files”;
$Body = “This is a test email which includes attachment”;
$mail = new PHPMailer();
$mail->From = $From;
$mail->FromName = $FromName;
$mail->AddAddress($To , $ToName);
$mail->WordWrap = 50; // set word wrap
$mail->Priority = 1;
$mail->IsHTML(true);
$mail->Subject = $Subject;
$mail->Body = $Body;
foreach($_FILES as $key => $file){
$target_path = “uploads/”;
$target_path = $target_path .basename($file[‘name’]);
if(move_uploaded_file($file[‘tmp_name’], $target_path)) {
echo “the file “.basename($file[‘name’]).” has been uploaded”;
}else {
echo “there was an error”;
}
$mail->AddAttachment($target_path);
}
$mail->AddAttachment(“imgj.jpg”);
$mail->AddAttachment(“Mailbox.png”); // attachment
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo ‘Message has been sent.’;
}
}
?>[/php]
Wud any one tell me, why is this php code doing nthng