1
사용자가 이메일을 입력하고 제출을 클릭하여 뉴스 레터를 요청할 수있는 매우 간단한 양식이 있습니다.전자 메일 주소를 메시지 본문에 표시하려면 어떻게합니까?
PHP는 전자 메일을 생성하지만 중요한 요소 중 하나는 가입자의 전자 메일을 포함하지 않습니다!
: 나는 이메일 통지를받을 때 메시지의 본문은 다음과 같은 포함, 그러나<?php $emailFrom = $_POST['email']; $emailTo = "[email protected]"; $subject = "Moving Simplified News Request"; if (!empty($emailFrom)) { $emailHeaders = 'From: "' . $emailFromName . '" <' . $emailFrom . '>'; } else { $emailHeaders = 'From: "The Boss" <[email protected]>'; } // Create a string representing the body. "\n" creates a new line. The ".=" operator appends the string onto the existing string. $body = "Email: ".$emailFrom."\n"; /* Send Email */ if (mail($emailTo, $subject, $body, $emailHeaders)) { echo 'Thank you! Your message has been sent.'; } else { echo 'There was an internal error while sending your email.<br>'; echo 'Please try again later.'; } ?>
: 여기
는 PHP입니다 : 여기 는 HTML입니다<form action="news.php" method="post"> <fieldset> <input type="text" id="your-email" value="YOUR EMAIL ADDRESS" onfocus="if (this.value=='YOUR EMAIL ADDRESS') this.value='';" /> <input type="submit" value="::Submit Query::" id="red-submit" /> </fieldset> </form>
이메일 :
나는 가입자는 다음과 같이 표시하는 이메일을 받고 어떤 도움을 주셔서 감사합니다 :
이메일 : [email protected]
감사합니다!
try $ body = "Email :".print_r ($ _ POST, true). "\ n"; 그러면 게시물의 모든 데이터를 인쇄 한 다음 전자 메일이 실제로 설정되었는지 확인할 수 있습니다. "true"는 print_r이 인쇄되지 않도록하고 변수로 지정할 수 있습니다. – Luke