이 메일 폼에는 보낸 사람이없고 메일이 곧장 쓰레기통으로가는 것을 제외하고는 모든 것이 작동합니다! 이 우편물에 발신자가 없기 때문입니까? 발신자로부터 정보를 얻으 려하므로 보낸 사람의 코드를 어디서 채울 수 있습니까?발신자가있는 PHP 메일
1
A
답변
2
당신은 메일로 "추가 헤더"인수를 사용하여 보낸 사람의 이메일 주소를 추가 할 수 있습니다
<?php
/* Set e-mail recipient */
$myemail = "[email protected]";
/* Check all form inputs using check_input function */
$name = check_input($_POST['inputName'], "Your Name");
$email = check_input($_POST['inputEmail'], "Your E-mail Address");
$subject = check_input($_POST['inputSubject'], "Message Subject");
$message = check_input($_POST['inputMessage'], "Your Message");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("Invalid e-mail address");
}
/* Let's prepare the message for the e-mail */
$message = "
Someone has sent you a message from xxxxxxx.com:
Name: $name
Email: $email
Subject: $subject
Message:
$message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: http://www.xxxxxxx.com/confirmation.html');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>
</body>
</html>
<?php
exit();
}
?>
:
mail($myemail, $subject, $message, "From: [email protected]");
편집을 : 귀하의 경우에, 나는 당신이 $ 이메일에 전달할 필요가 있다고 생각 변수에서 앞에서 정의한 변수. 그러면 양식에 입력 된 이메일 주소에서 온 것으로 이메일이 표시됩니다.
mail($myemail, $subject, $message, "From: " . $email);
참조 : 수동 (메일)에서 http://php.net/manual/en/function.mail.php
관련 문제
- 1. 발신자가있는 PHP 컬 포스트
- 2. 하나의 대리인과 많은 발신자가있는 프로토콜?
- 3. 발신자가있는 대기열의 이름을 가져옵니다. Twilio
- 4. PHP 메일/PEAR 메일
- 5. PHP 메일
- 6. 메일 (PHP)
- 7. PHP 메일()
- 8. PHP if() PHP if 문 PHP 메일()
- 9. PHP 메일 PHP 동적 PHP 내용 보내기
- 10. PHP 메일 기능 메일 테스트 기능이없는 전화
- 11. php 메일 기능 및 메일 서버
- 12. codeignitor 전자 메일 라이브러리를 사용하는 PHP 메일
- 13. PHP 메일 양식 임의 메일 보내기 매일
- 14. PHP 메일() 전자 메일 크기 제한
- 15. 실제 메일 전송 상태를 확인하십시오 (PHP 메일())
- 16. PHP 메일()을 사용하는 첨부 메일?
- 17. PHP 메일()을 사용하여 AngularJS로 메일 보내기
- 18. PHP 복수 수신자 메일
- 19. PHP 메일 기능 문제
- 20. PHP 메일 sanitisation 기술
- 21. PHP 메일 문제 해결
- 22. 첨부 파일이있는 php - 메일
- 23. PHP 메일() 함수는
- 24. PHP 테이블에서 메일 링하기
- 25. PHP 메일 보내기 file.html
- 26. PHP 메일 메시지 문제
- 27. php 메일 본문 문제
- 28. PHP 코드로 메일 보내기
- 29. 양식이없는 PHP 메일 링리스트
- 30. PHP 메일 인코딩
: 메일을 보낼 때 메일 헤더에서을 포함해야합니다. 이는 additional_headers 매개 변수로 설정하거나 php.ini에서 기본값을 설정할 수 있습니다. – Progrock
그런데, 저는 방금 램프 설정을 확인했고, 내 설정에는 'sendmail_from'값이 정의되어 있지 않습니다. 내 메일러 (exim4)는 헤더를 추가하지 않으면 스크립트를 실행하는 사용자의 보낸 사람 필드를 추가합니다. From 헤더가 전혀 없습니까? – Progrock