action php file downloading instead of executing [on hold]

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
/**
 * This example shows how to handle a simple contact form.
 */
$msg = '';
//Don't run this unless we're handling a form submission
if (array_key_exists('email', $_POST)) {
    date_default_timezone_set('Etc/UTC');
    require '../PHPMailerAutoload.php';
    //Create a new PHPMailer instance
    $mail = new PHPMailer;
    //Tell PHPMailer to use SMTP - requires a local mail server
    //Faster and safer than using mail()
    $mail->isSMTP();
    $mail->Host = 'mail.50webs.com';
    $mail->username = 'xxxxxxxx@xxxx.com';
    $mail->password = 'secret';
    $mail->Port = 25;
    //Use a fixed address in your own domain as the from address
    //**DO NOT** use the submitter's address here as it will be forgery
    //and will cause your messages to fail SPF checks
    $mail->setFrom('xxxx@xxxx.com', 'xxxxx');
    //Send the message to yourself, or whoever should receive contact for submissions
    $mail->addAddress('xxxxxxx@hotmail.com', 'xxxxx');
    //Put the submitter's address in a reply-to header
    //This will fail if the address provided is invalid,
    //in which case we should ignore the whole request
    if ($mail->addReplyTo($_POST['email'], $_POST['name'])) {
        $mail->Subject = 'PHPMailer contact form';
        //Keep it simple - don't use HTML
        $mail->isHTML(false);
        //Build a simple message body
        $mail->Body = <<<EOT
Name: {$_POST['name']}
Email: {$_POST['email']}
Company: {_POST['company']}
Contact_reason: {$_POST['Contact_Reason']}
Date From: {_POST['Date From']}
Date To: {_POST['Date To']}
Message: {$_POST['message']}
EOT;
        //Send the message, check for errors
        if (!$mail->send()) {
            //The reason for failing to send will be in $mail->ErrorInfo
            //but you shouldn't display errors to users - process the error, log it on your server.
            $msg = 'Sorry, something went wrong. Please try again later.';
        } else {
            $msg = 'Message sent! Thanks for contacting us.';
        }
    } else {
        $msg = 'Invalid email address, message ignored.';
    }
?>
    </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