doforumda Posted April 24, 2010 Share Posted April 24, 2010 hi i create a contact form. When user send me a message then at From column in my inbox i see something like this "example@eg.justhost.com". It should be "My Web". How can i make it to My Web instead of "example@eg.justhost.com" here is mu code <?php $name = strip_tags(addslashes($_POST['name'])); $email = strip_tags(addslashes($_POST['email'])); $message = strip_tags(addslashes($_POST['msg'])); if($name) { if($email) { if(ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { if($message) { $to = "web@example.com"; $from = "My Web"; $msg = $message; $subject = "Message from zafarsaleem.info"; $mail = mail($to,$subject,$msg,$from); //$mail = true; if($mail) { echo "Your message has been sent. Thank you for contacting."; } else echo "Sending message failed. Please try again later."; } else echo "Enter your message."; } else echo "Enter valid email address."; } else echo "Your email is required."; } else echo "Your name is required."; ?> Quote Link to comment Share on other sites More sharing options...
Zyx Posted April 24, 2010 Share Posted April 24, 2010 http://docs.php.net/manual/en/function.mail.php The last argument is not the name of the sender, but the list of additional mail headers. In other words, you must prepare a complete From header, like this: mail($to, $subject, $message, 'From: Me <webmaster@example.com>'); Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 24, 2010 Share Posted April 24, 2010 Look at this taken from php.net. <?php $Name = "Da Duder"; //senders name $email = "email@adress.com"; //senders e-mail adress $recipient = "PersonWhoGetsIt@emailadress.com"; //recipient $mail_body = "The text for the mail..."; //mail body $subject = "Subject for reviever"; //subject $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields ini_set('sendmail_from', 'me@domain.com'); //Suggested by "Some Guy" mail($recipient, $subject, $mail_body, $header); //mail command ?> James. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.