Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

php contact form not working on go daddy

the mail() function

Moderators: macek, egami, gesf

php contact form not working on go daddy

Postby terrigmc » Tue Jun 21, 2011 12:58 pm

I have this file set up and the from loaded on an html page. The from works and displays error messages and the thank you correctly but will not send the email to the account listed. Please advise.... very new to php and go daddy. I called their support and they were no help

Code: Select all

<?php
if(isset($_POST['email'])) {
     
    // CHANGE THE TWO LINES BELOW
    $email_to = "DolceAmicaEventPlanning@gmail.com";
     
    $email_subject = "Website Form Request";
     
     
    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }
     
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['telephone']) ||
       !isset($_POST['event']) ||
        !isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');     
    }
     
    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['telephone']; // not required
   $event_type = $_POST['event']; // not required
    $comments = $_POST['comments']; // required
     
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\n\n";
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
     
    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Telephone: ".clean_string($telephone)."\n";
   $email_message .= "Event Type: ".clean_string($event)."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";
     
     
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
 
<!-- place your own success html below -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
die();
?>


terrigmc
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Jun 21, 2011 12:55 pm

Re: php contact form not working on go daddy

Postby ravisoni6262 » Wed Jun 22, 2011 1:14 am

If you are testing this code on the server installed at your own site , kindly check for your SMTP installation, If have not installed it will surely not work ..
ravisoni6262
New php-forum User
New php-forum User
 
Posts: 13
Joined: Mon Jun 13, 2011 4:08 am

Re: php contact form not working on go daddy

Postby terrigmc » Wed Jun 22, 2011 5:44 am

I am using godaddy.com for my hosting. Not sure waht you mean my testing server on my own site?
terrigmc
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Jun 21, 2011 12:55 pm

Re: php contact form not working on go daddy

Postby egami » Wed Jun 22, 2011 7:13 am

goDaddy sucks.
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2197
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: php contact form not working on go daddy

Postby terrigmc » Wed Jun 22, 2011 11:49 am

Thats great that they suck but that does not answer how to solve my issue. Please refrain from posting garbage.
terrigmc
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Jun 21, 2011 12:55 pm

Re: php contact form not working on go daddy

Postby egami » Wed Jun 22, 2011 12:07 pm

why don't you take a quick look at this:
http://help.godaddy.com/article/510
http://community.godaddy.com/groups/web ... -not-work/
http://community.godaddy.com/groups/web ... send-mail/


You may also re-write your script to do something like this..

Code: Select all

$lame 
= mail($to,$subject,$body,$headers);
if ($lame) { 
  print_r
($lame);
}
 else { 
  echo 
"Mail not sent, most likely I don't have configuration 2.0+, or I don't have my login credentials to the SMTP server set correctly.";
}
 
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2197
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron