올바르게 수행하고 있는지 또는 가능한지 확실하지 않습니다. 기본적으로 변수 $ cascadeType의 값에 따라 테이블 <td>
의 배경색 만 변경하면됩니다. 사용자 입력을 받아PHPMailer : 전자 메일 템플리트의 조건문
형태 : 다음 파일 CascadeFunction.php 처리 도착 상기 폼
<form action="CascadeFunction.php" method="post" name="cascader" id="cascader" enctype="multipart/form-data">
<label><span class="required">*</span>CASCADE TYPE</label><br /><br />
<label for="Release" class="radioitem">RELEASE
<input type="radio" name="cascadeType" value="Release" id="CascadeType_1" /></label>
<label for="Update" class="radioitem">UPDATE
<input type="radio" name="cascadeType" value="Update" id="CascadeType_2" />
</label>
<label for="Reminder" class="radioitem">REMINDER
<input type="radio" name="cascadeType" value="Reminder" id="CascadeType_3" /></label>
<label for="Information" class="radioitem">INFORMATION
<input type="radio" name="cascadeType" value="Information" id="CascadeType_4" /></label>
<input class="btn btn-primary" name="Submit" type="submit" id="submit" value="POST & CASCADE" />
</form>
제출 데이터. 이메일을 보낼 수는 PHPMailer 코드는 여기서
<?php
// starting the session
session_start();
if (isset($_POST['Submit'])) {
$_SESSION['cascadeType'] = $_POST['cascadeType'];
}
?>
그런 다음 내에서 세션에 액세스 : 변수 $ cascadeType를 저장하기위한 시도
$mail->IsHTML(true); // This tells the PhPMailer that the messages uses HTML.
$mail->MsgHTML(str_replace('%cascadeType%', $CascadeType, file_get_contents('emailtemplates/emailtemplate.php')), dirname(__FILE__));
다음 코드에서 볼 수 있듯이, 나는 _SESSIONS를 사용하여 $ 시도 코드를 사용하여 이메일 템플릿 ( emailtemplate.php ) : 전자 메일 템플릿 내에서, 그리고
<?php
// starting the session
session_start();
?>
을 (emailtemplate.php), 아래의 조건문을 사용했습니다.
<tr>
<?php if ($_SESSION['cascadeType'] = "Information") : ?>
<td style="text-align:center; color:#FFF; background-color:#093; margin:10px; padding:10px 5px;" width="20%">
<h4 style="font-weight:bold;">%cascadeType%</h4>
</td>
<?php elseif ($_SESSION['cascadeType'] = "Update") : ?>
<td style="text-align:center; color:#FFF; background-color:#09F; margin:10px; padding:10px 5px;" width="20%">
<h4 style="font-weight:bold;">%cascadeType%</h4>
</td>
<?php elseif ($_SESSION['cascadeType'] = "Reminder") : ?>
<td style="text-align:center; color:#FFF; background-color:#F00; margin:10px; padding:10px 5px;" width="20%">
<h4 style="font-weight:bold;">%cascadeType%</h4>
</td>
<?php else : ?>
<td style="text-align:center; color:#FFF; background-color:#6C3; margin:10px; padding:10px 5px;" width="20%">
<h4 style="font-weight:bold;">%cascadeType%</h4>
</td>
<?php endif ; ?>
<td style="color:#337AB7; text-align:right; padding-right: 20px;" width="80%">
<h3 style="margin-bottom:2px;">TARGET AUDIENCE</h3>
<p style="margin-top:2px;">%targetAudience%</p>
</td>
이메일 출력은 작동하지 않습니다 분명히 모든 테이블 <td>
를 표시합니다. 조건문이 전자 메일 서식 파일 내에서 실제로 작동하지 않는 경우 상황에 가장 잘 접근하는 방법에 대해 조언하십시오.
로드/실행 방법을 말하지 않았습니다. – Synchro
@ 싱크로, 고마워. 나는 내 질문을 변경했다. 희망이 도움이됩니다. –