Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 24, 2012, 12:02:15 PM

Pages: [1]   Go Down
  Print  
Author Topic: Php form "from" address  (Read 12772 times)
webweaver
Galactic Royalty
*****
Offline Offline

Posts: 206


WWW
« on: December 05, 2011, 12:22:50 PM »

Partially solved: I have a php form that submits to email. It works great, but when the form results mail is received it says it is from myUsername@servername.lunarpages.com. This "from" email does not fill the needs of the person receiving the form results.   She would like the "from" field on the emailed form results to be the email address of the person submitting the form, so it could be replied to if further information is needed.  I do not see where in either the form code or the processing code where to put this  "from" information. Can anyone provide a code snippet that will solve my problem and (politely) tell me where to put it?  Very Happy? I am new to php. Progress so far seems to indicate I need to put in a "headers" section, so will dabble with that for now.

OK, solved one part of it by using headers for a reply to.  It still has the ugly email address in the from field, but if she can get beyond that and just hit reply it will put the submitters email in the reply to field. Would like to solve the second part but could not get headers From to work. This is all on a member section, but step 2 is a similar process on the public side so I would be interested in advice on securing all this...  Am reading furiously of course, but sure do like the advice of lunar people.  Mr. Phil where are you? ;-)  

Webweaver

« Last Edit: December 05, 2011, 08:46:33 PM by webweaver » Logged
lexhair
Galactic Royalty
*****
Offline Offline

Posts: 406


« Reply #1 on: December 07, 2011, 10:56:07 AM »

Just use PHPMailer. Simple and easy.
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5215



« Reply #2 on: December 07, 2011, 04:15:58 PM »

Mr. Phil where are you? ;-)  
Right here. Just let me get out my kazoo and play the "Mighty Mouse" fanfare... Geez, I must be getting some kind of reputation!

So you're using PHP's mail(), or are you using some other form of mailing library? If mail(), for the fourth argument you're giving "From: xyz@mysite.com" style? If that doesn't override the default AccountName@server.lunarwhatever.com, you might need to open a support ticket. It sounds like it knows the real email address (what you gave for "From:") shows up when replying? In what other places does the default email address show up, and does the correct email address show up?

Maybe you could show us a sample email that isn't working (dummy names and content, of course), along with the PHP code. I seem to vaguely recall hearing about this problem from time to time, not necessarily at LP. I trust that you've done an extensive search, both with the forum search and with Google? Maybe you're using mail() and your account is configured to use SMTPmail() or something, or vice-versa?
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
webweaver
Galactic Royalty
*****
Offline Offline

Posts: 206


WWW
« Reply #3 on: December 07, 2011, 07:25:03 PM »

Mr Phil,

Thanks for looking in (hearing your theme song in background...)

Using PHP's mail/

and the form works great.  the gal who will be handling these has gotten over being disturbed by the odd "from" now that she can just hit reply to contact the form submitter.  But of course I wonder what I could do differently. Ideally I would like to set up a no-reply or automated response email address to use as the from but before I can do that, I have to figure this out. It seems to just be picking the "from" field off the server (via php.ini maybe???) because I don't see anything in my coding that tells me it is doing that.  That being said, I have a limited understanding of the coding I used.  I thought I understood each part of it, but I did cobble together information found in various locations.And even so, I would prefer that other members not get the main email address. 

I have sent you a personal message with all the coding but now that I hit send, it does not show up in my PM "outbox" so let me know if you don't get it.
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5215



« Reply #4 on: December 08, 2011, 05:57:51 AM »

Change
Code:
$headers = "From: information@*******.org \r\n";
$headers = "Reply-To: $visitor_email \r\n";
to
Code:
$headers = "From: information@*******.org \r\n";
$headers .= "Reply-To: $visitor_email \r\n";

Your problem was that you didn't add the Reply-To to the From $headers; you replaced the From $headers with it. You want to add both into $headers. $headers will now contain both, but not having my references handy, I think it's the right syntax.

Also read: http://stackoverflow.com/questions/2014081/problem-with-php-mail-from-header . Is your From address registered with your account? Some hosts overwrite the From address to prevent spoofing/phishing if they don't think it's legitimate.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
webweaver
Galactic Royalty
*****
Offline Offline

Posts: 206


WWW
« Reply #5 on: December 08, 2011, 07:20:04 AM »

Mr. Phil.

Thank you, that did it.  I KNEW you would have my answer. 

I had seen the issue shown in stackflow and have noted it so I will recognize it if it starts happening.

I might get your feedback on security issues when I have my other form developed but that will be later in the month or January.

Lunar Forums is GRAND!


Webweaver
Logged
webweaver
Galactic Royalty
*****
Offline Offline

Posts: 206


WWW
« Reply #6 on: December 08, 2011, 07:22:02 AM »

 LexHair,

Thank you for your suggestion.  If I get deeper in trouble will look into it.

Webweaver
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: