引导邮件格式$ from <$ email> $ fromEmail

时间:2018-06-29 02:51:26

标签: mail-form formmail

我参考此页。 https://bootstrapious.com/p/how-to-build-a-working-bootstrap-contact-form和我使用index-2.html / contact-2.php文件。

我要邮件头”

但是代码是

**$fromEmail = 'demo@domain.com';
$fromName = 'Demo contact form';**
$sendToEmail = 'my@mail.com';
$fields = array('name' => 'Name', 'phone' => 'Phone', 'email' => 'Email', "\r\n" , 'message' => 'Message');

所以我改变了

$fromEmail = "$email" $fromName = '$name'; or
$fromEmail = $_POST['form_email'];  $name = $_POST['name'];

但是它只会出错。 例)根用户”“'

try
{

if(count($_POST) == 0) throw new \Exception('Form is empty');

$emailTextHtml .= "<table>";

foreach ($_POST as $key => $value) {
    // If the field exists in the $fields array, include it in the email
    if (isset($fields[$key])) {
        $emailTextHtml .= "<tr><th>$fields[$key]</th><td>$value</td></tr>";
    }
}
$emailTextHtml .= "</table>";

$mail = new PHPMailer;

$mail->setFrom($fromEmail, $fromName);
$mail->addAddress($sendToEmail, $sendToName); // you can add more addresses by simply adding another line with $mail->addAddress();
$mail->addReplyTo($from);

$mail->isHTML(true);

$mail->Subject = $subject;
$mail->msgHTML($emailTextHtml); // 

我该怎么办?

$ fromEmail ='demo@domain.com'; $ fromName ='演示联系人表格'

我应该如何更改?

0 个答案:

没有答案