通过PHPmailer发送HTML表
我正试图用PHPmailer发送一个动态HTML表,但我不知道如何,是否可以用all表获取一个变量?或者类似的 这是我的密码:通过PHPmailer发送HTML表,php,mysql,phpmailer,Php,Mysql,Phpmailer,我正试图用PHPmailer发送一个动态HTML表,但我不知道如何,是否可以用all表获取一个变量?或者类似的 这是我的密码: require("inc/class.phpmailer.php"); $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; $mail->From = ('compras.co@kantarworldpanel.com'); $mail->FromName = ('Compras CO (KWB
require("inc/class.phpmailer.php");
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->From = ('compras.co@kantarworldpanel.com');
$mail->FromName = ('Compras CO (KWBTA)');
$mail->AddAddress($_POST['providermail']);
$mail->AddCC("camilo.uribe@kantarworldpanel.com.co");
$mail->IsHTML(true);
//IF SUBMIT, SEND MAIL
if (isset ($_POST['send_approve'])) {
$mail->Subject = "Kantar Worldpanel - Solicitud de Cotización";
$contenido = 'Kantar Worldpanel Perú S.A. Sucursal Colombia desea solicitar a ustedes la cotización correspondiente a los siguientes Items:<br>';
////////////////////////////////////////////
$contenido .= ' The Table should be here;
///////////////////////////////////////////
$mail->Body = $contenido;
$mail->Send();
header ("Location: RequestsPA.php");
}
require(“inc/class.phpmailer.php”);
$mail=new PHPMailer();
$mail->CharSet='UTF-8';
$mail->From=('compras。co@kantarworldpanel.com');
$mail->FromName=('Compras CO(KWBTA)');
$mail->AddAddress($_POST['providermail']);
$mail->AddCC(“卡米洛。uribe@kantarworldpanel.com.co");
$mail->IsHTML(true);
//如果提交,请发送邮件
如果(isset($\u POST['send\u approve'])){
$mail->Subject=“Kantar Worldpanel-Clarcud de Cotización”;
$contenido='Kantar Worldpanel PerúS.A.Sucursal Colombia desea la cotización corresponder A los siguientes Items:
';
////////////////////////////////////////////
$contenido.='桌子应该在这里;
///////////////////////////////////////////
$mail->Body=$contenido;
$mail->Send();
标题(“位置:RequestsPA.php”);
}
以下是表格代码:
<?php
$sqlStr = "SELECT items.CA_id, items.item_id, items.item_Cant, items.CECO_cod, items.item_desc, items.item_enduser
FROM items where CA_id = ".$CA_id;
$sqlStrAux = "SELECT count(*) as total FROM items";
$aux = Mysql_Fetch_Assoc(mysql_query($sqlStrAux));
$query = mysql_query($sqlStr);
if($aux['total']>0){
echo "</br></br>";
echo "<div class='datagrid'>";
echo "\t<table class=\"tablesorter\">\n";
echo "<thead>";
echo "<tr>
<th>Item</th>
<th>Cantidad</th>
<th>CECO</th>
<th>Descripción de solicitud</th>
<th>Usuario final</th>
</tr>\n";
echo "</thead>";
echo "<tbody>";
$r=0;
while($row = mysql_fetch_assoc($query)){
echo "\t\t<tr class=\"row$r\">
<td>".htmlentities($row['item_id'])."</td>
<td>".htmlentities($row['item_Cant'])."</td>
<td>".htmlentities($row['CECO_cod'])."</td>
<td>".$row['item_desc']."</td>
<td>".$row['item_enduser']."</td>
</tr>\n";
if($r%2==0)++$r;else--$r;
}
echo "</tbody>";
echo "\t</table>\n";
}
echo "</div>";
?>
虽然您可以使用echo输出表并捕获它,但通常更容易将消息体组合成字符串,如下所示:
$contenido = '';
if($aux['total']>0){
$contenido .= "</br></br>";
$contenido .= "<div class='datagrid'>";
$contenido .= "\t<table class=\"tablesorter\">\n";
$contenido .= "<thead>";
...
$contenido='';
如果($aux['total']>0){
$contenido.=“”;
$contenido=”;
$contenido.=“\t\n”;
$contenido=”;
...
然后将该字符串用作消息正文。如果使用与电子邮件内容相同的代码生成网页输出,则将该脚本转换为一个可以从任意位置调用的函数
ob_start();
echo 'all my lines of code';
$contenido = ob_get_clean();
以上内容将捕获第一行和最后一行之间的所有内容。是否发送表或表内的变量?