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

Php form sending copy to form email address but not to us?

the mail() function

Moderators: macek, egami, gesf

Php form sending copy to form email address but not to us?

Postby Acknowledged74 » Mon Oct 01, 2012 2:01 pm

Hi

We have finally got a PHP Mail() form working after changing hosts, well I say working.

I've filled out the form to test it with my own email and on submission it successfully sends me a copy, but doesn't sent the business the original email submission. I've included the relevant code below can anyone tell what I'm missing please?

Code: Select all
$myFile = "log.txt";
      $log = 'Availability Check ============================'."\r\n".'Name: '.$name."\r\n".'Email: '.$email."\r\n".'Phone: '.$phone."\r\n".'Number of Cats: '.$cats."\r\n".'Arrival Date: '.$Adate."\r\n".'Collection Date: '.$Ddate."\r\n".'Days: '.$fullDays."\r\n".'Message:'."\r\n".$message."\r\n".'Heard About Us From: '.$hearabout."\r\n".'';
      $log = str_replace('&','&',$log);
      $fh = fopen($myFile, 'a') or die("can't open file");
      $stringData = "$log\n";
      fwrite($fh, $stringData);
      fclose($fh);

      $to      = 'cats@cats.co.uk';
      //$to      = 'john@petadmin.com';
      $subject = 'Enquiry from: '.$name;
      $message = 'Availability Check ============================'."\r\n".'Name: '.$name."\r\n".'Email: '.$email."\r\n".'Phone: '.$phone."\r\n".'Number of Cats: '.$cats."\r\n".'Arrival Date: '.$Adate."\r\n".'Collection Date: '.$Ddate."\r\n".'Days: '.$fullDays."\r\n".'Message:'."\r\n".$message."\r\n".'Heard About Us From: '.$hearabout."\r\n".'';
      $message = str_replace('&','&',$message);
      $headers = 'From: donotreply.cats@petadmin.com' . "\r\n" .
         'Reply-To: '.$email.'' . "\r\n" .
         'X-Mailer: PHP/' . phpversion();

      mail($to, $subject, $message, $headers);

      $Usermessage = 'Thank you for checking availability with cats; the information below has been sent to us. We will contact you to discuss the details or alternatively, please feel free to call us.'."\r\n".$message;
      $subject = 'Checking availability with cats.co.uk';

      if (!empty($email)) {
         mail($email, $subject, $Usermessage, $headers);
      }


I need the form to be sent to cats@cats.co.uk but it just isn't doing it for some reason?

I'm with GoDaddy hosting who apparently run PHP 5.2 if that makes any difference?

Please any help would be great, its terrible not having this work on the website.

Ash
Acknowledged74
New php-forum User
New php-forum User
 
Posts: 5
Joined: Mon Oct 01, 2012 1:55 pm

Re: Php form sending copy to form email address but not to u

Postby seandisanti » Tue Oct 02, 2012 11:34 am

if the script is going to be hosted at godaddy, try using relay-hosting.secureserver.net as your smtp host.


***edit***
if you try to do that from wamp, or a local instance, it will give you 553 errrors, but once the script is being run from their server it should work fine.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 787
Joined: Mon Oct 01, 2012 12:32 pm

Re: Php form sending copy to form email address but not to u

Postby Acknowledged74 » Tue Oct 02, 2012 12:14 pm

Not using SMTP?

The code is sending the the customer who fills in the form to the email they put in, but just not to us.

Surely that's a coding issue not a hosting?
Acknowledged74
New php-forum User
New php-forum User
 
Posts: 5
Joined: Mon Oct 01, 2012 1:55 pm


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