PHPMailer发送更多值

时间:2013-10-22 19:50:39

标签: php

我熟悉PHP,所以我需要这方面的帮助:

我在PHPmailer表单中添加了新变量,但是如何设置将它们发送到电子邮件?

这是我认为必须修改的代码:

    $mail = new PHPMailer();
    $mail->From       = $conf['email_sent_from'];
    $mail->FromName   = $conf['email_sent_from_name'];
    $mail->Subject    = $conf['email_subject'];
    $mail->WordWrap   = 50; // some nice default value

    $mail->Body = $values['message']; <-- this code
    $mail->AddReplyTo( $values['email'] );
    $mail->AddAddress( $conf['email_to'] );

这些都是价值观:

$values = array(
    'webname'       => $_POST['webname'],
    'business'      => $_POST['business'],
    'name'      => $_POST['name'],
    'email'     => $_POST['email'],
    'phone'     => $_POST['phone'],
    'message'   => $_POST['message'],
    );

我想要网络名称,商家,姓名,电子邮件,电话和广告;信息在身体里。我怎么能这样做?

是否有一种HTML自定义方式?喜欢添加&lt; br&gt;

1 个答案:

答案 0 :(得分:2)

价格便宜且脏,格式最小

$mail->Body = implode('<br>',$values);

多一点格式化,确保使用html电子邮件

$body="<table>";
foreach ($values as $k=>$v){

$body.='<tr><td>'.$k.'</td><td>'.$v.'</td></tr>';
}
$body.="</table>";

$mail->IsHTML(true); // its html mail baby
$mail->Body =$body;