 <p>This should work for you.</p> <pre><code>require '/PHPMailer-master/PHPMailerAutoload.php'; require '/PHPMailer-master/class.phpmailer.php'; $mail = new PHPMailer(true); if(isset($_POST['submit'])){ $to = "me@mymail.com"; $from = $_POST['text_96']; $fullname = $_POST['text_95']; $email = $_POST['text_96']; $dob = $_POST['date_12']; $addr = $_POST['textarea_31']; $maths = $_POST['text_93']; $english = $_POST['text_31']; $holidayst = $_POST['date_74']; $holidayend = $_POST['date_91']; $distance = $_POST['number_58']; $awayhome = $_POST['selectlist_90']; foreach($_POST['checkbox'] as $key=&gt;$val){$apprent .= $val.' ';} //$fileatt = $_POST['file']; $reasontext = $_POST['textarea_60']; $message = "Message"; $mail-&gt;setFrom($from, $fullname); $mail-&gt;addAddress('me@mymail.com'); $mail-&gt;addAttachment($_FILES['file']['name']); if (isset($_FILES['file']) &amp;&amp; $_FILES['file']['error'] == UPLOAD_ERR_OK) { $mail-&gt;AddAttachment($_FILES['file']['tmp_name'], $_FILES['file']['name']); } $mail-&gt;Subject = 'subject'; $mail-&gt;Body = $message; try{ $mail-&gt;send()) { header('Location: success.html'); }catch(Exception $e) { header('Location: error.html'); } finally{ $message = NULL; $headers = NULL; } } </code></pre>