开发者

PHP email form, how to bypass host limitation? (Can ONLY send/receive IF hosting sender/receiver)

My webhost ONLY allows sending/recieving emails IF either the sender or reciever is hosted with them. (freehostia.com)

This is a huge disadvantage to me (and I'm assuming everyone else), because of the way my website works.

(My website: I have a classifieds website where CustomerA posts an ad with her email and CustomerB replies via the email form with his email. Neither email is hosted with my host.)

I asked if I could use an external SMTP server (such as Gmail) to bypass the limitations, and they said "Even if you set an external MX开发者_如何学编程 record for your domain you will not be able to send e-mails via your mail forum, if you do not use a mailbox from your hosting account with us as a sender or recipient."

Theoretical Workaround:

  1. Auto-enter and hide my hosted email into the "email" section of the form
  2. Have a new section for customer to input their email
  3. When a message is sent, embed customers message and email into a default message. It will look like this:

To: customerA@example.com

From: DONOTREPLY@example.com

Subject: You have recieved a message!

Body: Blahblahblah (customers message) blahblah. To reply, email: customerB@example.com


Sorry about all the confusion. Would this work? Should I give up? I really like my host, but should I switch? Or is there a better workaround?


While you don't need to send through a different server, you can just send to whom you need and set the reply to any address you want.

The mail function allows you to set your own headers as a final parameter.

$headers = 'Reply-To: someone@some_other_domain.com\n\r';
mail($to, $subject, $body, $headers);


You can set the reply-to address.

That way even though the email is sent from your address, when the recipient hits reply it creates an email to the address given in the reply-to.

I'm not sure what you are using to send mail but there are some examples in the PHP documentation mail function - http://php.net/manual/en/function.mail.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜