nitindb Posted February 11, 2010 Share Posted February 11, 2010 Currently the contact form seems to take the email address entered by users as the 'from' address. What I need to do is to specify my own 'from' address (e.g. [email protected]) and have the email address entered by the user as the 'replyto' address which is displayed within the message. Can someone guide me as to how I would do this? Link to comment Share on other sites More sharing options...
nitindb Posted February 12, 2010 Author Share Posted February 12, 2010 I found the answer to this now. Inside contact-form.php, there is a section which has two instances of $from (approx line 26). I changed these both to:- '[email protected]'. The contact form works like a charm now! Link to comment Share on other sites More sharing options...
farrvince Posted May 13, 2016 Share Posted May 13, 2016 Where is contact-form.php. I can't find it! Link to comment Share on other sites More sharing options...
rkuzma Posted October 17, 2019 Share Posted October 17, 2019 I don't know where to change the code here. <?php $errors = ''; $myemail = '[email protected]';//<-----Put Your email address here. if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message'])) { $errors .= "\n Error: all fields are required"; } $name = $_POST['name']; $email_address = $_POST['email']; $message = $_POST['message']; if (!preg_match( "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email_address)) { $errors .= "\n Error: Invalid email address"; } if( empty($errors)) { $to = $myemail; $email_subject = "Contact form submission: $name"; $email_body = "You have received a new message. ". " Here are the details:\n Name: $name \n Email: $email_address \n Message \n $message"; $headers = "From: $myemail\n"; $headers .= "Reply-To: $email_address"; mail($to,$email_subject,$email_body,$headers); //redirect to the 'thank you' page header('Location: http://www.webpage.html'); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Contact form handler</title> </head> <body> <!-- This page is displayed only if there is some error --> <?php echo nl2br($errors); ?> </body> </html> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now