简体   繁体   中英

Need Help Adding code to make this send to my email address

I made this contact form, and when you hit send it brings you to a thank you screen, but I do not know how to make it send to my email address. If someone can help me with that I would appreciate it.

ContactUs html file

<form action="mail.php" method="post">
<p>Name</p> <input type="text" name="name">
<p>Email</p> <input type="text" name="email">

<p>Priority</p>
<select name="priority" size="1">
<option value="Low">Low</option>
<option value="Normal">Normal</option>
<option value="High">High</option>
</select>
<br />

<p>Type</p>
<select name="type" size="1">
<option value="update">Question</option>
<option value="change">Information Change</option>
<option value="addition">Information Addition</option>
<option value="new">Misc.</option>
</select>
<br />

<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br />
<input type="submit" name="sendemail" value="Send"><input type="reset" value="Clear">
</form>

mail php file

<?php
if(isset($_POST["sendemail"]))
{
$name = $_POST['name'];
$email = $_POST['email'];
$priority = $_POST['priority'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent=" From: $name \n Priority: $priority \n Type: $type \n Message: $message";
$recipient = "dnasim09@gmail.com";
$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;'> Go Somewhere you are already home ;)</a>";
}
?>

try this https://github.com/PHPMailer/PHPMailer

you can configure an smtp to send emails, I guess the problem with your code is that your server does not have any email sending method, you need an smtp to send emails

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM