Jump to content

email address and contact form snag


judkels

Recommended Posts

I am most grateful for all the advice and I'm sorry to be asking all these questions. Should it ever happen that I know the answer to someone else's query I shall jump in - a bit unlikely just at the moment!

This is the problem I now have.

My contact php form is working thanks to help from falkencreative.

However I am finding that if I use the address I'd like to use ie enquiries@xxxx.com where xxxx.com is the domain name (and this email address seems to work everywhere else) the form doesn't work and I get an undelevered reply as below. If I use any other email address ie hotmail yahoo and so on it seems to work fine.

Why is this happening - is it my code or something else I have done wrong.

 

This is the undelivered message I get

 

This message was created automatically by mail delivery software.

 

A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:

 

enquiries@mysite.com

No Such User Here

 

------ This is a copy of the message, including all the headers. ------

 

Return-path: <me@hotmail

Received: from chilli by sv14.premiumwebserver.com with local (Exim 4.69)

(envelope-from <me@hotmail>)

id 1OvGmA-0000OD-5c

for enquiries@mysite.com; Mon, 13 Sep 2010 16:41:22 -0500

To: enquiries@mysite.com

Subject: Feedback from website

From: me@hotmail

Reply-To: me@hotmail

Message-Id: <E1OvGmA-0000OD-5c@sv14.premiumwebserver.com>

Date: Mon, 13 Sep 2010 16:41:22 -0500

 

Name: .....

Message: \....\' ...

do hope these are now arriving ok

No virus found in this incoming message.

Checked by AVG - www.avg.com

 

This is my php code that seems to work if I use any other address in place of the enquiries@mysite.com

 

<?php

$email_to = "enquiries@mysite.com";

$name = $_POST["name"];

$email_from = $_POST["email"];

$message = $_POST["message"];

$email_subject = "Feedback from website";

$headers = "From: $email_from" . "\r\n" .

"Reply-To: $email_from";

$message = "Name: ". $name . "\r\nMessage: " . $message;

ini_set("sendmail_from", $email_from);

$sent = mail($email_to, $email_subject, $message, $headers, "-f" .$email_from);

if ($sent)

{

header("Location: http://www.mysite.com/thankyou.html");

} else {

echo "There has been an error sending your comments. Please try later.";

}

?>

 

 

Can you see where I have gone wrong?

Link to comment
Share on other sites

You may want to check this line:

 

$headers = "From: $email_from" . "\r\n" .

 

It depends on the web host, but often when using PHP's mail() function, they expect that the from address share the same domain as the website. You may try changing that line to use a different email address (for example: noreply@yourdomain.com -- the actual email doesn't have to exist) and that may fix things.

 

That's just a rough guess though... I'm assuming that "enquiries@mysite.com" is a valid, working email address?

Link to comment
Share on other sites

You may want to check this line:

 

$headers = "From: $email_from" . "\r\n" .

 

It depends on the web host, but often when using PHP's mail() function, they expect that the from address share the same domain as the website. You may try changing that line to use a different email address (for example: noreply@yourdomain.com -- the actual email doesn't have to exist) and that may fix things.

 

That's just a rough guess though... I'm assuming that "enquiries@mysite.com" is a valid, working email address?

 

No that didn't make any difference and yes the enquiries@mysite.com email address works fine. I have sent and received messages using this on outlook - to make sure it was spelt correctly I cut and pasted the address into the php code.

The words used in the error message I receive say 'No Such User Here' does that imply I have to add it somewhere and if so why do the other email addresses not with the domain name work? I know these do work as I've checked this with a friend. Quite odd.

Link to comment
Share on other sites

This is something that you may want to talk to your web host. I'm not seeing anything wrong with the form, and it is strange that it sends fine to other email addresses, just not the one on your domain.

 

Yes i think that must be it - I trawled through google for something similar and found this which seems plausable from a thread here a couple of years ago http://www.webhostingtalk.com/showthread.php?t=703306 the answer being to remove the domain listed in /etc/localdomains. I shall have to refer to the web host as you suggest and see what they do as a solution - I can see all sorts of folders and one called etc but nothing in it that I can alter.

thanks for your advice

Judy

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...