2013-08-30 3 views
0

양식이 있습니다. 나는 등록한 여러 사람들에게 이메일을 보내고 보내는 "게시"방법을 사용하고 있습니다. 그런 다음 이메일의 $ body는 템플릿을 기반으로합니다. 데이터베이스 없음, 클래스 없음, 단순한 형식. 예, 이것에 관해서는 이미 읽었습니다. 모두 거기에 있습니다. 나는이 사건과 관련하여 그것을 모을 수 없었습니다. 텍스트 파일에서 내용 가져 오기 및 키워드 바꾸기 PHP

"email_template.txt는"같은 것을해야한다 텍스트 :

<?php 
//form and validation 
$firstname = "John"; // inputed name on the form, let say 
$lastname = "Doe"; // inputed last name 
$email = "example"; // inputed email 

//email message 
$body = ... some type of a get_file_content.... 
mail($_POST['email'], 'Party Invitation', $body, 'From: [email protected]'); 
?> 
:

Hello #firstname# #lastname#. Thank you for registering! Your registered email is #email# 

내 PHP에 PHP

Hello **John Doe**. Thank you registering! Your registered email is **[email protected]**. 

에 의해 처리에 다음과 같이겠습니까을 내가 좋아하는 뭔가를

$ body는이 PHP 양식을 통해 제출 된 등록자에게 보내는 전자 메일 메시지입니다.

답변

0

sprintf와 좋은

템플릿이 될 수 있습니다 작동합니다

안녕하세요 %의 %의. 등록 해주셔서 감사합니다! 등록 된 이메일은 % s입니다.

$ body = sprintf ($ fileContents, $ firstname, $ lastname, $ email);

또는 str_replace(), 꽤 많이 발견됩니다.

$ body = "Hello # firstname # # lastname #. 등록 해 주셔서 감사합니다. 등록 된 이메일은 # email #"입니다.

$ body = str_replace ("# firstname #", $ firstname, $ body);

$ body = str_replace ("# lastname #", $ lastname, $ body);

$ body = str_replace ("# email #", $ email, $ body);

+0

어떻게 든 작동하지 않습니다 .... $ body = file_get_contents (email_template.txt); $ body = str_replace ("# firstname #", $ firstname, $ body); $ body = str_replace ("# lastname #", $ lastname, $ body); $ body = str_replace ("# email #", $ email, $ body); – mythoslife

+0

신경 쓰지 마세요. – mythoslife

+0

ok 따옴표를 찾았습니다. :) – surivitna

관련 문제