action php file downloading instead of executing

Good Evening,

I’m trying to send an e-mail to my personal e-mail address with phpmailer. I’m creating a php file for the phpmailer and then I’m setting the form action to this file. When I upload the page to my site and test it, instead of executing the action as it should it’s downloading the file and not sending an e-mail. Here is my code:

<form class="contactform" onsubmit="return validateForm()" action="email.php" `   method="post" enctype="text/plain">

And the php file code:


$mail = new PHPMailer();

$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->Host = "";  // specify main and backup server
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "xxxxxx";  // SMTP username
$mail->Password = "xxxxxxxx*"; // SMTP password

$mail->From = "xxxxx";
$mail->FromName = "webmaster";
$mail->AddAddress("xxxxxx", "Bryan Sayles");
$mail->AddAddress("bxxxxxxxxx");                  // name is optional
$mail->AddReplyTo("xxxxxx", "Webmaster");

$mail->WordWrap = 50;                                 // set word wrap to 50 characters
$mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = "Contact form response";
$mail->Body    = "$message $contactreason $name </b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;

echo "Message has been sent";

I saw there is a similar question on here but my problem seems different as I didn’t forget the tags. Thanks for your help.


Leave a Reply