Sending an email using a php contact form -


i trying create contact form using php. when click send email appears have sent recipient never receives it. maybe need set smtp server unsure how this. in advance

in form.html have

<form action="mail.php" method="post"> <p>name</p> <input type="text" name="name"> <p>email</p> <input type="text" name="email"> <p>phone</p> <input type="text" name="phone">  <p>request phone call:</p> yes:<input type="checkbox" value="yes" name="call"><br /> no:<input type="checkbox" value="no" name="call"><br />  <p>website</p> <input type="text" name="website">  <p>priority</p> <select name="priority" size="1"> <option value="low">low</option> <option value="normal">normal</option> <option value="high">high</option> <option value="emergency">emergency</option> </select> <br />  <p>type</p> <select name="type" size="1"> <option value="update">website update</option> <option value="change">information change</option> <option value="addition">information addition</option> <option value="new">new products</option> </select> <br />  <p>message</p><textarea name="message" rows="6" cols="25"></textarea><br /> <input type="submit" value="send"><input type="reset" value="clear"> </form> 

in mail.php file have

<?php $name = $_post['name']; $email = $_post['email']; $phone = $_post['phone']; $call = $_post['call']; $website = $_post['website']; $priority = $_post['priority']; $type = $_post['type']; $message = $_post['message']; $formcontent=" from: $name \n phone: $phone \n call back: $call \n website: $website \n        priority: $priority \n type: $type \n message: $message"; $recipient = "kerrip90@hotmail.co.uk"; $subject = "contact form"; $mailheader = "from: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("error!"); echo "thank you!" . " -" . "<a href='form.html' style='text-    decoration:none;color:#ff0099;'> return home</a>"; ?> 

for mail() function work can install postfix on server issuing command:

sudo apt-get install postfix 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -