1

I have a contact us form, whereby the user enters his name,email address and question.

The user enters his name, email address and the question. The question is sent to my inbox and then from my inbox when i click on the mail, reply, i should be able to reply to the email which the user inserted,

Email client is gmail

using the code below, it is not working,

$mail->SMTPAuth = true;

$mail->Username = "info@noupei.com";

$mail->Password = "xxxxxxxxxxxxxxxxx"; 

$mail->AddAddress("info@noupei.com",$Username);

$mail->AddReplyTo($UserEmailAddress,$Username);

$mail->IsHTML(true); 

$mail->Subject = "From ContactUs Form:".$Username;

the mail is comming into my inbox but when I'm pressing reply, it is replying to my inbox itself

hakre
  • 193,403
  • 52
  • 435
  • 836
Noor
  • 19,638
  • 38
  • 136
  • 254
  • Which client are you using? Have you looked into the mail headers and if they were set correctly? – Hikaru-Shindo Jan 11 '12 at 09:30
  • @Hikaru-Shindo, actually, i'm getting the mail into info@gmail.com but the problem is when i press reply, the reply address is info@gmail.com – Noor Jan 11 '12 at 09:40

3 Answers3

2

Which email client are you using?

$mail->AddReplyTo($UserEmailAddress,$Username); 

should be

$mail->AddReplyTo("$UserEmailAddress", "$Username")

Setting a From and FromName would also be advisable. If you don't set one yourself a default is pulled from php.ini which will either be a default domain or could be a domain other than your own!

Dave

detheridge02
  • 640
  • 1
  • 6
  • 18
2

This is a known "bug" in Gmail:

http://www.google.com/support/forum/p/gmail/thread?tid=4641785bf01dbd9a&hl=en

As long as your own email address is the From-address Gmail seems to not honor the Reply-To headers.

Hikaru-Shindo
  • 1,891
  • 12
  • 22
0

Is it possible that your SMTP server doesn't allow for different from and reply-to headers? You should check the headers of the email that you get if reply-to is really set to what it should be and maybe consider setting the from address to the reply-to address. That should definitly solve the problem.

$mail->FromName = $Username;
$mail->From = $UserEmailAddress;

Edit:

Gmail might be the problem here. For one it does more or less ignore the reply-to header as it seems and there seems to be an issue if the To address is also in the 'Send Mail As...' settings. Google Support Forum

  • It seems that gmail has some issues with different reply-to and from headers. See for example: [http://stackoverflow.com/questions/2421234/gmail-appearing-to-ignore-reply-to]. Setting the From to the reply-to address did not work? Does this mean you still reply to another address but the it shows the correct from header? – Christopher Jan 11 '12 at 09:46
  • it might also have to do with this [http://www.google.com/support/forum/p/gmail/thread?tid=74d00d5e2605242d&hl=en] Quote: "I believe I have proved (with my own tests) there is a bug when the incoming To: address is also set up in your settings as a 'Send Mail As...' account." Is this the case? – Christopher Jan 11 '12 at 09:55