Hoàn thành một ví dụ sử dụng gửi mail xampp (ok)
testmail.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form role="form" id="contact-form" method="post" action="http://localhost/php/contact.php">
<label for="name">Name</label>
<input type="text" placeholder="Full Name" name="name" required>
<label for="email">Email</label>
<input type="email" placeholder="Your Email" name="email" required>
<label>Message</label>
<textarea name="message" placeholder="Your Message" rows="9"></textarea>
<button type="submit" class="btn">Send</button>
</form>
</body>
</html>
contact.php
<?php
$to = 'phamngoctuong1805@gmail.com' . "\r\n";
$subject = 'Subject';
$name = $_POST['name'];
$email = $_POST['email'];
$message = "************************************************** \r\n" .
"Message from you website! \r\n" .
"************************************************** \r\n" .
"Name: " . $name . "\r\n" .
"E-mail: " . $email . "\r\n" .
"Message: " . $_POST["message"] . "\r\n";
$headers = "From: " . $name . "<" . $email . "> \r\n" .
"Reply-To: " . $email . "\r\n" .
"MIME-Version: 1.0" . "\r\n" .
"Content-type:text/html;charset=UTF-8" . "\r\n";
mail($to, $subject, $message, $headers);
?>
Last updated