Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 918343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:21:36+00:00 2026-05-15T18:21:36+00:00

I just purchased a website template from DreamTemplate.com, and have tried to send a

  • 0

I just purchased a website template from DreamTemplate.com, and have tried to send a test e-mail from it online and instead of sending the e-mail it just comes up with red text saying: “ERROR!”.

I am not very familiar with PHP, but I can understand the syntax. The code is below:


Contact.html

<script type="text/javascript">
    // <![CDATA[
    jQuery(document).ready(function () {
        $('#contactform').submit(function () {
            var action = $(this).attr('action');
            $.post(action, {
                name: $('#name').val(),
                email: $('#email').val(),
                company: $('#company').val(),
                subject: $('#subject').val(),
                message: $('#message').val()
            }, function (data) {
                $('#contactform #submit').attr('disabled', '');
                $('.response').remove();
                $('#contactform').before('<p class="response">' + data + '</p>');
                $('.response').slideDown();
                if (data == 'Message sent!') $('#contactform').slideUp();
            });
            return false;
        });
    });
    // ]]>
</script>

Contact.PHP

<?php

if(!$_POST) exit;

$email = $_POST['email'];


//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
    $error.="You've entered an invalid e-mail address.";
    $errors=1;
}
if($errors==1) echo $error;
else{
    $values = array ('name','email','message');
    $required = array('name','email','message');

    $your_email = "enquiries@ourdomain.com";
    $email_subject = "New Message: ".$_POST['subject'];
    $email_content = "new message:\n";

    foreach($values as $key => $value){
      if(in_array($value,$required)){
        if ($key != 'subject' && $key != 'company') {
          if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
        }
        $email_content .= $value.': '.$_POST[$value]."\n";
      }
    }

    if(@mail($your_email,$email_subject,$email_content)) {
        echo 'Message sent!'; 
    } else {
        echo 'ERROR!';
    }
}
?>

Can someone please help? I have no idea why this won’t work. Any help at all is much appreciated.

Thank you


Update:
As advised, I have removed the @ symbol before ‘mail’. It is now displaying useful error messages:

“Warning: mail() [function.mail]: Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in E:\web\autoopti\contact.php on line 31
ERROR!”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:21:37+00:00Added an answer on May 15, 2026 at 6:21 pm

    Posting another answer based on the OP’s edit.

    Are you running this on your local machine, or on another Windows server? You need to have a SMTP server running on the machine you’re trying to execute mail() from. Please see these articles: One Two for basic instructions on setting up an SMTP server, or Google has the answers.

    Quick explanation of what an SMTP server is and does: it’s the mail relayer. The SMTP server implements the messaging protocols to route e-mails to their appropriate destination(s).

    EDIT: If you feel like diving headfirst into PHP, and don’t want to bother setting up a local SMTP server, you can use PHPMailer to use your ISP’s or another remote SMTP server, where it’s already configured for you. There’s plenty of sample code out there.

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used opera unite for deploying a static html/css/javascript website just for fun.
I just purchased a hosting account from Go Daddy with a SQL Server database
I just purchased an SSL certificate from my hosting provider, at the request of
I just purchased a SSL certificate from Go Daddy. Great price, but it seems
I have just started learning struts 2. I have purchased the book named Struts
Basically, i have purchased HTC Hero (Android sdk 1.5) , but i just got
I have just purchased Tonic Gallery which my client thinks it's absolutely perfect for
Just checking my JS and I have an error, but I cannot see where.
just wanted to ask where I define initial class properties? From other languages I
Just a knowledge question which I would like to ask: For example, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.