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:

<body>
<?php
require("class.PHPMailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->Host = "mail.50webs.com";  // 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";

if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";
?>
</body>

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.

Related:


Leave a Reply