나는 얼마 동안이 문제를 해결해 왔으며 PHP를 처음 접했습니다. 나는 이것을 보내는데 문제가있다. 이 코드에 대한 눈의 두 번째 세트는 가장 도움이 될 것입니다 :양식에서 전자 메일을 보내려는 HTML/PHP
<?php
if(isset($_POST['submit'])){
$to = "myEmail"; // this is your Email address
$from = $_POST['emailAddress']; // this is the sender's Email address
$fullName = $_POST['fullName'];
$subject = "Form submission";
$message = $fullName . " wrote the following:" . "\n\n" . $_POST['comment'];
$message2 = "Here is a copy of your message " . $fullName . "\n\n" . $_POST['comment'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $fullName . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
<form method="post" action="contact.php">
<div class="form-group">
<label for="fullName">Name</label>
<input type="text" class="form-control" id="fullName" name="fullName" placeholder="Jane Doe">
<label for="emailAddress">Email</label>
<input type="email" class="form-control" id="emailAddress" name="emailAddress" placeholder="[email protected]">
<label for="comment">Comment</label>
<textarea class="form-control" rows="3" name="comment" placeholder="Comment"></textarea>
<button name="submit" type="submit" class="btn">Submit</button>
</div>
</form>
많은 감사합니다! 두 번째 메일 기능의 코드 매개 변수에서
어떤 오류가 발생합니까? 코드가 조건부에 들어가 있습니까? 하드 코딩 된 값을 가진 한 줄의 mail() 호출을 성공적으로 실행할 수 있습니까? – mkaatman
로컬 서버에서는 PHP 메일 기능이 작동하지 않지만 PhpMailer (https://github.com/PHPMailer/PHPMailer)를 사용할 수 있습니다. –
코드에 아무 것도 표시되지 않습니다. 어떤 오류가 발생 했습니까? 또한 @mkaatman이 모인 상태에서 다른 페이지의 일반 메일() 기능으로 이메일을 보낼 수 있습니까? –