0

我参考这个页面。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 = '演示联系表'

我应该如何改变它?

4

0 回答 0