我正在编写支持票据站点并需要电子邮件功能(PEAR),我一直在解决这个问题:
“No From:已提供地址”下面是脚本的一部分,显示我认为问题所在,请注意:敏感信息已被删除/编辑。
感谢:
$replyto = "REDACTED";
$host = "REDACTED";
$username = "REDACTED";
$password = "REDACTED";
$mime = '1.0';
$content = 'text/html; charset=ISO-8859-1';
$subject = $subject;
$mime = "1.0";
$content = "text/html; charset=ISO-8859-1";
$headers = array ('From ' => $replyto,
'To ' => $to,
'Reply-To ' => $replyto,
'Mime-Version ' => $mime,
'Subject: ' => $subject,
'Content-Type' => $content);
$smtp = Mail::factory('smtp', array('host'=>$host,
'auth'=> true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to,$headers,$body);
if(PEAR::isError($mail)) {
echo "ERROR: Could not send email: " . $mail->getMessage();
} else {
$url = "http://support.myfallen.net/ticket.php?id=" . $internalId . "&successCode=1";
header('Location:' . $url);
}
答案 0 :(得分:2)
由于某些奇怪的原因,$ params数组中的所有键都以' '
结尾 - 一个空白符号。即,而不是......
array ('From ' => $replyto, ...
......应该是......
array ('From' => $replyto, ...
所有其他键('To'
代替'To '
,'Reply-To'
代替'Reply-To '
,'Subject'
代表'Subject: '
等相同。 )。