1

I'm trying to send attachments (pdf, doc, docx) from a form using

class.phpmailer.php I can send pdf's but not doc or docx files.

Not sure how to incorporate the doc or docx files.

Any feedback would be great.

Below is the code I have so far, i'm pretty new to PHP trying to learn as

I go. Thank you!

 <?php
include("_includes/PHPMailer/class.phpmailer.php");

if(file_exists('/tmp/resume.pdf')){
    unlink('/tmp/resume.pdf');
}
if(isset($_POST['passed'])){
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $comment = $_POST['comment'];

    #validate File
    $File = $_FILES['resume']['tmp_name'];
    move_uploaded_file($File, "/tmp/resume.pdf");

    $to_name = "Spartan X Customer Support";
    $subject = "Website User, " . $name . ", Submitted a Resume";
    $message = "Name: " . $name . "\n E-mail: " . $email . "\n Phone Number: ". $phone . "\n Comment: " . $comment;
    $from = "Spartan X Website User";
    $to = "cfez@dm.marketing";  
    $mail = new PHPMailer(); 
    $mail->FromName = $from;
    $mail->From = "user@spartanx.com";
    $mail->AddAttachment("/tmp/resume.pdf");
    $mail->AddAddress($to, "Spartan X");
    $mail->Subject = $subject;
    $mail->Body = $message;

    if(!$mail->Send()) {
        $error = "Mailer Error: " . $mail->ErrorInfo;
        }else{ $success = "Message sent!";
    }
}else{header( 'Location: /index.html' ) ;}
?>

0 Answers0