email - PHP - Send E-Mail From Any Address -
i working on website, , website, need have form can filled out sending e-mail. form must have place first , last name, place e-mail address e-mail being sent from, , place e-mail address message being sent to, place message subject, , of course, place message. know possible because have seen done in past, not know how it. please offer me this? appreciated.
edit
html
<div id="contact" align="center"> <!--contact instructions--> <h1 align="center">contact us</h1> <p style="font-size:20px"> @ bottom of page find contact form in can submit questions. please describe problem best of ability, more details give us, faster response, , solution. </p> <form action="notphp.php" method="post" id="contact form" style="font-size:18px"> first name: <input type="text" name="first" required placeholder="required"> <br> last name: <input type="text" name="last" placeholder="optional"> <br> email: <input type="email" name="email" required placeholder="required"> <br> question: <textarea required name="question" placeholder="required" id=" question" cols="100" rows="10"></textarea> <br> <input type="submit" value="submit" id="sendbutton"> </form> </div> </body> </html>
php
<?php $first = $_post['first']; $last = $_post['last']; $email = $_post['email']; $question = $_post['question']; if(mail("somebogusemailaddress@gmail.com", $first." question", "name: ".$first." ".$last." ".$email."\n".$question)) echo("your question submited."); else echo ("your message not submitted successfully, please try again."); ?> <html> <head> <script type="text/javascript"> <!-- function redirect() { window.location="index.html"; } document.write("your message has been accepted. redirected home page in moment."); settimeout('redirect()', 5000); //--> </script> </head> </html>
to set 'from address' of email, need set in headers.
$headers = 'from: '.$email_from."\r\n". 'reply-to: '.$email_from."\r\n" . 'x-mailer: php/' . phpversion(); $email_to = 'test@test.com'; $email_subject = 'this subject'; mail($email_to, $email_subject, $email_message, $headers);
Comments
Post a Comment