为了账号安全,请及时绑定邮箱和手机立即绑定

将 php $headers 放在特定联系表格中以更改电子邮件“发件人”地址的位置

将 php $headers 放在特定联系表格中以更改电子邮件“发件人”地址的位置

PHP
catspeake 2021-08-28 15:46:35
我正在尝试$headers = "From: webmaster@example.com\r\n";在 PHP 中使用将联系表单上的“发件人”电子邮件地址设置为“name@companyname.com”。它参考了这个答案PHP 邮件函数“来自”地址我对 php 很陌生,所以如果答案很明显,我很抱歉,但它让我不知所措。表格的代码如下,但我似乎无法让它工作?有谁知道我将如何/在哪里将它与下面的代码集成在一起。亲切的问候,<?php     if($_POST['submit']) {        if(!$_POST['name']) {            $error="<br>- Please enter your name";        }        if(!$_POST['email']) {            $error.="<br>- Please enter your email";        }        if(!$_POST['telephone']) {            $error.="<br>- Please enter your telephone number";        }        if(!$_POST['message']) {            $error.="<br>- Please enter your message";        }        if(!$_POST['checkbox']) {            $error.="<br>- Please confirm you agree to the Privacy Policy";        }        if ($error) {            $result='<div class="alert error">Whoops, there is an error. Please correct the following: '.$error.'</div>';        } else {        mail("name@company.com", "Contact Message", "Name: ".htmlspecialchars($_POST['name'])."            Email: ".htmlspecialchars($_POST['email'])."            Telephone: ".htmlspecialchars($_POST['telephone'])."            Company: ".htmlspecialchars($_POST['company'])."            Budget: ".htmlspecialchars($_POST['budget'])."            Message: ".htmlspecialchars($_POST['message']));            {                $_POST= array();                $result='<div class="alert thankyou" role="alert">THANK YOU! WE\'LL BE IN TOUCH SHORTLY...</div>';            }        }    }?>
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 135 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信