0

I'm using phpmailer to send mail and attachment, everything works fine but I don't know how to specify type of attachment that can be uploade (only .pdf, .doc type). Thank you for your help

<form method="post" action="mail.php" enctype="multipart/form-data">
<input type="file" name="attachmentFile" id="attachmentFile" class="form-control"  placeholder="Add file">                  
</form>

In my mail.php, I have following code

require('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = TRUE;
$mail->AuthType = "PLAIN";
$mail->SMTPSecure = "tls";
$mail->Port     = 587;  
$mail->Username = "XXX";
$mail->Password = "XXX";
$mail->Host     = "mail.XXX.net";
$mail->SetFrom("$email");
$mail->AddAddress("XXX@gmail.com"); 
$mail->Subject = "Mail";
$mail->WordWrap   = 80;
$mail->MsgHTML("test");
if(is_array($_FILES)) {
$mail->AddAttachment($_FILES['attachmentFile']['tmp_name'],$_FILES['attachmentFile']['name']); 
}
$mail->IsHTML(true);
if(!$mail->Send()) {
    echo "<p class='error'>Not send, try again.</p>";
    $mail->Body    = "Thanks";
} else {
    echo "<p class='success'>Sent,thx!</p>";
}   
Deby
  • 3
  • 2

0 Answers0