Wrapping up hidden email address email formNow we are going to wrap it up. This is the file that does all of the work. It checks to make sure the form fields are filled in, checks to see if the data came from the form, removes malicious tags, and sends an email to you and your visitor.... Whew!
<?php // Start
parsing PHP
////////////////////////////////////////////////////////////////////////////
//If all of the validation passes above, we will process the data. //////////////////////////////////////////////////////////////////////////// // Give the visitor an instant confirmation on screen. echo "<h3>$f_name- Your message has been sent. <br / >Please check your $e_mail mailbox</h3>"; echo " Sender: $f_name $l_name<br>"; echo "Reply To: $e_mail<br>"; echo "Subject: $subject<br>"; echo "Your Message: $content<br>"; //send confirming email //This is what you want sent to you, so change it to your email address $receiver1 = "yoursite@yourplace.com"; // Change this email to your address $subject1 = "An Email Request from $f_name $l_name"; $message1 .= "Visitor: $f_name $l_name\n"; $message1 .= "Subject: $subject\n"; $message1 .= "Email: $e_mail\n"; $message1 .= "Email Message: $content\n\n"; $message1 .= "$f_name - Notice that nowhere along the line did your email address ever appear to anyone. Reason? When You clicked Send Email, your server sent the message internally. Nowhere was your real address ever revealed. Nice Huh?\n\n"; $headers1 = "From:MY Email Form\r\n"; // Change this to your id prefernce mail ($receiver1, $subject1, $message1, $headers1); unset ($receiver1, $subject1, $message1, $headers1); // NOTE: You can add more message1's or modify the text in the existing message1's. Just be sure to not lose any quotes or periods. Same with message2's below. //To the visitor to confirm the email was sent $receiver2 = "$e_mail"; $subject2 = "Email Confirmation"; $message2 .= "$f_name- This is an automated confirmation that your email has been received by My email Form.\n"; // Change My email form to your identity $message2 .= "Thank you for working through our email tutorial.\n\n"; // Change this to reflect your message $message2 .= "Your Message: $content\n\n"; $message2 .= "----------------------------------------------\n"; $message2 .= "Please do not reply to this message. To contact us email us at MY EMAIL FORM\n"; //Change the MY EMAIL FORM to the address you want visitors to email. $message2 .= "----------------------------------------------\n"; $headers2 = "From:MY Email Form\r\n"; // Change this too mail ($receiver2, $subject2, $message2, $headers2); unset ($receiver2, $subject2, $message2, $headers2); ?> <!-- End the PHP and wrap up the html code to close the page --> </body> </html>
|