我需要从下拉列表的每个选择中通过电子邮件发送多个电子邮件地址,但是我尝试过的所有方法都无法正常工作。
我在表格的开头使用了这个
$mailto = $_POST['unit'];
这就是我的下拉框
<select name="unit" size="1" id="Combobox1" style="position:absolute;left:43px;top:324px;width:61px;height:21px;z- index:18;">
<option value= '[email protected]'; '[email protected]'> M17</option>
<option value="[email protected]">M16</option>
</select>
问题
1.在选项M17上,它仅发送到第一个电子邮件地址
2.它发送了电子邮件地址,而不是单元号(M17)
。3.需要找出一种通过单独的“用户”编辑电子邮件地址的方法友好”页面
</head>
<body>
<div id="space"><br></div>
<div id="container">
<div id="wb_Form1"
<form name="11_Dispatch" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="Form1">
<input type="hidden" name="formid" value="form1">
<div id="wb_Text1" style="position:absolute;left:10px;top:76px;width:111px;height:16px;z-index:0;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Address</span> </div>
<input type="text" id="Editbox1" style="position:absolute;left:131px;top:76px;width:198px;height:23px;line-height:23px;z-index:1;" name="LOC" value="">
<div id="wb_Text2" style="position:absolute;left:10px;top:106px;width:111px;height:16px;z-index:2;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Subdivision</span></div>
<input type="text" id="Editbox2" style="position:absolute;left:131px;top:106px;width:198px;height:23px;line-height:23px;z-index:3;" name="SUB" value="">
<div id="wb_Text3" style="position:absolute;left:10px;top:136px;width:111px;height:16px;z-index:4;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Call back # </span></div>
<input type="text" id="Editbox3" style="position:absolute;left:131px;top:136px;width:198px;height:23px;line-height:23px;z-index:5;" name="#" value="">
<div id="wb_Text5" style="position:absolute;left:10px;top:166px;width:111px;height:16px;z-index:6;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Chief Complaint</span></div>
<input type="text" id="Editbox4" style="position:absolute;left:131px;top:166px;width:198px;height:23px;line-height:23px;z-index:7;" name="CC" value="">
<div id="wb_Text6" style="position:absolute;left:10px;top:196px;width:111px;height:16px;z-index:8;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Pt name</span> </div>
<input type="text" id="Editbox5" style="position:absolute;left:131px;top:196px;width:198px;height:23px;line-height:23px;z-index:9;" name="NAME" value="">
<div id="wb_Text7" style="position:absolute;left:10px;top:226px;width:111px;height:16px;z-index:10;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Pt Age</span> </div>
<input type="text" id="Editbox6" style="position:absolute;left:131px;top:226px;width:198px;height:23px;line-height:23px;z-index:11;" name="AGE" value="">
<div id="wb_Text9" style="position:absolute;left:10px;top:256px;width:111px;height:16px;z-index:12;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Callers Name</span></div>
<input type="text" id="Editbox7" style="position:absolute;left:131px;top:256px;width:198px;height:23px;line-height:23px;z-index:13;" name="CALLER" value="">
<div id="wb_Text10" style="position:absolute;left:10px;top:286px;width:111px;height:16px;z-index:14;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Identifying Factors</span></div>
<input type="text" id="Editbox8" style="position:absolute;left:131px;top:286px;width:198px;height:23px;line-height:23px;z-index:15;" name="NOTES" value="">
<input type="submit" id="Button2" name="" value="Dispatch" style="position:absolute;left:169px;top:357px;width:96px;height:25px;z-index:16;">
<div id="wb_Text12" style="position:absolute;left:166px;top:30px;width:133px;height:22px;z-index:17;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:19px;"><strong>911 Dispatch</strong></span></div>
<select name="unit" size="1" id="Combobox1" style="position:absolute;left:43px;top:324px;width:61px;height:21px;z-index:18;">
<option value="M17">M17 </option>
<option value="M16">M16</option>
<option value="M15">M15</option>
<option value="M14">M14</option>
<option value="M11">M11</option>
<option value="M10">M10</option>
<option value="M07">M07</option>
</select>
</form>
如建议的那样,不要将您的to
地址放在表格中。这只是基本知识,而mail()
部分内容恰好来自于手册-> http://php.net/manual/zh-CN/function.mail.php(示例#4发送HTML电子邮件显示了使用串联的多个电子邮件收件人,但是,我使用的是内爆):
PHP:
if(isset($_POST['unit'])) {
// Store emails in the code or database to draw from:
// Personally I like to store this in an array (if I were to hardcode it)
// Reason being, is that if you suddenly one day get access to a database
// and you draw a bunch of email addresses from that database, those emails
// would likely be listed as an array.
// By storing each email in a same-named array, you basically
// create an easy-to-read mailing list
$units['m17'][] = '[email protected]';
$units['m17'][] = '[email protected]';
$units['m16'][] = '[email protected]';
// if the <select> value of $_POST['unit'] equals 'm17'
// $units[$_POST['unit']] then is the same as $units['m17']
$to = implode(",",$units[$_POST['unit']]);
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]'."\r\n";
// As noted in the PHP Manual, the function implode() takes an array
// and combines the values into a string with a "glue", in this case a comma
// $to would then equal: "[email protected],[email protected]" if
// $_POST['unit'] equals 'm17'.
mail($to, $subject, $message, $headers);
}
形式:
<select name="unit" size="1" id="Combobox1" style="position: absolute; left: 43px; top: 324px; width: 61px; height: 21px; z-index: 18;">
<option value="m17">M17</option>
<option value="m16">M16</option>
</select>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句