[英]php mail() from email not the same as what I sent through header
I am trying to send an email using the mail function, while the email goes through on my local, it is not on hosted server. 我正在尝试使用邮件功能发送电子邮件,尽管该电子邮件在我的本地计算机上通过,但不在托管服务器上。 The one thing that is very out of place on both servers is the "from" email address I am trying to pass through the header using mail().
两台服务器上非常不合适的一件事是我尝试使用mail()通过标头传递的“发件人”电子邮件地址。
Both servers are getting the same "from" email address to send in my code. 两台服务器都使用相同的“发件人”电子邮件地址来发送我的代码。 But my email results are very different.
但是我的电子邮件结果却大不相同。 There the "From" email address in the emails that are in my inbox have "myname@my-name.local" for my local server "www-data" for my hosted server
收件箱中的电子邮件中的“发件人”电子邮件地址中,本地服务器的名称为“ myname@my-name.local”,托管服务器的名称为“ www-data”
What I have it set as in my email "from" header is: noreply@domain.com 我在“发件人”邮件头中设置的内容是:noreply@domain.com
$to = "my.name@gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
date_default_timezone_set('America/Los_Angeles');
$date = date("F j, Y, g:i a");
$title = checkValue('title', $_POST['title']);
$first_name = checkValue('first name', $_POST['first-name']);
$last_name = checkValue('last name', $_POST['last-name']);
$email = checkValue('email address', $_POST['email']);
$state = checkValue('state', $_POST['state-province']);
$zip = checkValue('zip', $_POST['zip']);
$city = checkValue('city', $_POST['city']);
$country = checkValue('country', $_POST['country']);
$addressOne = checkValue('address 1', $_POST['address-1']);
$addressTwo = checkValue('address 2', $_POST['address-2']);
// get phone and format
$phoneArr = checkArrayValues($_POST['phone']);
$phone = '['.$phoneArr['0'].'] ['.$phoneArr['1'].'] ['.$phoneArr['2'].']';
// get fax and format
$faxArr = checkArrayValues($_POST['fax']);
$fax = '['.$faxArr['0'].'] ['.$faxArr['1'].'] ['.$faxArr['2'].']';
$message = checkValue('message', $_POST['message']);
$topic = checkValue('topic', $_POST['subject']);
$emailBody = '
<html>
<head>
<title>HELLO</title>
</head>
<body>
<label>##Referrer##www.zout.com/contact-us##</label><br />
<label>##Date## '.$date.'##</label><br />
<label>##Topic## '.$topic.'##</label><br />
<label>##First Name## ['.$first_name.']##</label><br />
<label>##Last Name## ['.$last_name.']##</label><br />
<label>##Street## ['.$addressOne.'], ['.$addressTwo.']##</label><br />
<label>##Postal Code## ['.$zip.']##</label><br />
<label>##City## ['.$city.']##</label><br />
<label>##State## ['.$state.']##</label><br />
<label>##Country of residence## ['.$country.']##</label><br />
<label>##Phone## ['.$phone.']##</label><br />
<label>##Fax## ['.$fax.']##</label><br />
<label>##Email## ['.$email.']##</label><br />
<label>##Message## ['.$message.']##</label><br />
</body>
</html>';
$headers = -"From: noreply@domain.com" . "\r\n";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to,$topic,$emailBody,$headers);
What is the cause for this and how can I fix it? 这是什么原因造成的,我该如何解决? Thanks a lot
非常感谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.