我正在使用PHPMailer收集表单数据并发送并自动回复用户的邮件。我有3个不同的单选按钮可供选择。我需要根据所选的单选按钮来自定义自动响应。
<form action="mailer.php" method="POST" name="xform">
<input type="radio" name="summit" id="summit" value="bird" >
<label for="summit">regular</label>
<input type="radio" name="summit" id="summit1" value="duck">
<label for="summit1">vip</label>
<input type="radio" name="summit" id="summit2" value="eagle">
<label for="summit2">vvip</label>
<button name="submitted" type="submit" >Send</button>
</form>
For PHPMAILER
if(isset($_POST['submitted'])){
$which = $_POST['summit'];
<!--this picks the selected radio button value -->
}
<!--For Autoresponse -->
if($mail->send()){
$autoemail->Body = "I need a way to customize this body of the auto respose mail in accordance with the selected radio button, like if $which is an array, how do I customize the auto response in accordance with the selected child";
}
请注意,我的PHPMAILER配置正常运行,没有任何问题。
答案 0 :(得分:1)
嗯,您需要在发送消息之前先设置正文 !
要根据您的单选按钮值选择不同的邮件正文,
switch($_POST['summit']) {
case 'bird':
$mail->Body = "Message body 1";
break;
case 'duck':
$mail->Body = "Message body 2";
break;
case 'eagle':
$mail->Body = "Message body 3";
break;
}
$mail->send();
当然,您可以从任何来源获取消息内容-从外部文件,数据库,外部HTTP请求等-只要将MailMailer放入{{1 }}。