Unstoppable Domains

Php mail form problem

Spaceship Spaceship
Watch
Impact
338
Hi everybody,

I tried to add an autorespond message to one of my php forms, and it worked...
(and that is exciting because i am not a programmer at all, my php knowledge stops after"hello world")

But.....the sender who fills out my form receives the autoresponder from "nobody" send with my servername emailaddress (e.g Nobody [[email protected]] )...i would like that to be from the email address defined in $to

Anybody out to my rescue?

Here is the code:

<?php

$betreff = "Booking Form";
$to = "[email protected]";
$sender = "From: $email<$email>";
$mailbody = "From: $fname $lname\n";
$mailbody = $mailbody."company $company\n";
$mailbody = $mailbody."phonenumber:$phone\n";
$mailbody = $mailbody."eMail: $email\n\n";
$mailbody = $mailbody."phone2: $phone2\n\n";
$mailbody = $mailbody."Event Date: $eventdate\n\n";
$mailbody = $mailbody."Event Time: $eventtime\n\n";
$mailbody = $mailbody."Duration: $duration\n\n";
$mailbody = $mailbody."Number of People: $people\n\n";
$mailbody = $mailbody."Kind opf Event: $eventkind\n\n";
$mailbody = $mailbody."Private Area : $private\n\n";
$mailbody = $mailbody."Providing Drinks : $drinks\n\n";
$mailbody = $mailbody."Providing Food: $food\n\n";
$mailbody = $mailbody."Special Needs : $specials\n\n";
$mailbody = $mailbody."Special Needs : $specials1\n\n";
$mailbody = $mailbody."Special Needs : $specials2\n\n";
$mailbody = $mailbody."Special Needs : $specials3\n\n";
$mailbody = $mailbody."Special Needs : $specials4\n\n";
$mailbody = $mailbody."Special Needs : $specials5\n\n";
$mailbody = $mailbody."Special Needs : $specials6\n\n";
$mailbody = $mailbody."Comment : $comment";
mail($to, $betreff, $mailbody, $sender);
mail($sender, "this is an autoresponder");
?>

Cheers

Frank
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
Notice that your last line of code:
PHP:
mail($sender, "this is an autoresponder");

Only contains 2 parameters, whereas the one above it contains 4:
PHP:
mail($to, $betreff, $mailbody, $sender);

The parameters for the mail function:
http://php.net/manual/en/function.mail.php

So I think you want:
PHP:
mail($sender, "this is an autoresponder","message",$to);
 
0
•••
*EDIT* Doh! Ignore statement read first post wrong :p -NC- has you covered ;)

-RageD
 
0
•••
Hi Guys,

The last line was wrong when i posted, sorry...
But i exchanged it with the code from NC and all what i get is the booking form/response...no autoresponder at all

(Unfortunately like i said, i am a total noob and if i ask stupid questions forgive me) I am no longer affiliated with my house php coder who helped me out with things like that :(

Any other ideas?

Regards,

Frank
 
0
•••
Just had another look and $sender might be a valid from address, but it might not work for to. ( because of the other text in it, e.g. "from:" ).

try:
PHP:
 mail($email, "this is an autoresponder","message",$to);
 
0
•••
Hi NC,

No luck, all what i get is the booking form with the infos, no autoresponder(i am used differnt email addresses to check)

Well, i guess i have to hire someone her....i will post in the other forum :(

But thx for your help..

Cheers,

Frank
 
0
•••
Try

Code:
mail($to, $betreff, $mailbody, $sender);
mail($sender, "this is an autoresponder", $mailbody, "From: $to\r\n");

$to is "[email protected]". The 4th parameter need to be a mail header (i.e. "From: [email protected]").

Note - make sure that you check $email before this function to avoid abuse of your mail form (I'm assuming $email is a GET/POST variable).

qbert
 
0
•••
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back