Ok here's the deal. I have a contact form that people use to email a client on a site.
There are a few fields on the page that are required to be input - Name, Email Address, Phone Number, and of course the Message itself.
This script works great but whats happening is when the email message arrives at its destination, it says it is coming from a default mail server from network solutions (where site is hosted). I'd like to see the inputted email address come up in the Network Solutions email program as the from email address as opposed to the network solutions default mail server email.
Can anyone help me out with this? I am very new to PHP and any help would be greatly appreciated.
<?php
$show_confirmation = false;
if(isset($_POST['action']) && $_POST['action'] == 'send') {
/* Set this variable to the email address you want the form to be submitted to: */
$to_email = 'info@ccestatemanagement.com';
/* Set this variable to be the Subject of the email that is received with the form submission. */
$subject = "CCEM Contact Form Submission";
/* Set this to be the text you want displayed to the user after they submit the form: */
$confirmation_text = "Your information has been sent. Thank You.";
$isOk=true;
if(!isset($_POST['name']) || preg_match("/^\s*$/", $_POST['name']) ) {
$bad_name=true;
$isOk = false;
}
if(!isset($_POST['email']) || preg_match("/^\s*$/", $_POST['email']) ) {
$bad_email=true;
$isOk = false;
}
if(!isset($_POST['phone']) || preg_match("/^\s*$/", $_POST['phone']) ) {
$bad_phone=true;
$isOk = false;
}
if($isOk) {
$message = "Contact Form Submission Details:\n==================================\n";
$message .= "Name:\t".$_POST['name']."\n";
$message .= "Email:\t".$_POST['email']."\n";
$message .= "Phone:\t".$_POST['phone']."\n";
if(isset($_POST['message'])) {
$message .= "Message:\t".$_POST['message']."\n";
}
mail($to_email, $subject, $message);
}
$show_confirmation = $isOk;
}
?>
Question about my Mail Code..
Moderator: General Moderators
Re: Question about my Mail Code..
Take a look at the $additional_headers argument to mail. Check the examples and user comments.
Re: Question about my Mail Code..
Tas...I understand the concept but dont really understand the syntax. Not sure how to take something a user inputs as an email address and then set a variable to that email address. I am learning still.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Question about my Mail Code..
Code: Select all
$headers = 'From: ' . $_POST['name'] . '<' . $_POST['email'] . '>' . "\r\n";mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.