我正在尝试使用邮件功能发送电子邮件,而电子邮件在我的本地发送,它不在托管服务器上。在两台服务器上非常不合适的一件事是"来自"电子邮件地址我试图使用mail()传递标题。
两个服务器都是相同的"来自"要在我的代码中发送的电子邮件地址但我的电子邮件结果却截然不同。在那里" From"收件箱中的电子邮件中的电子邮件地址 " myname@my-name.local"为我的本地服务器 " www数据"对于我的托管服务器
我在电子邮件中设置的内容"来自"标题是: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);
这是什么原因以及如何解决? 非常感谢