无法在OpenShift中通过php邮件发送邮件
我一直在尝试一些php代码,但无法通过以下代码发送邮件。我几天前发送过邮件,但现在无法在OpenShift中通过php邮件发送邮件,php,email,Php,Email,我一直在尝试一些php代码,但无法通过以下代码发送邮件。我几天前发送过邮件,但现在mail()函数返回true,但邮件不在收件人的收件箱中。代码如下: $to = "test@example.com"; $subject = "Testing Emails"; $emailBody = "Hello"; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1"
mail()
函数返回true,但邮件不在收件人的收件箱中。代码如下:
$to = "test@example.com";
$subject = "Testing Emails";
$emailBody = "Hello";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: Test <no-reply@example.com>" . "\r\n";
$headers .= "Reply-To: no-reply@example.com"."\r\n";
$mail = mail($to,$subject,$emailBody,$headers);
if($mail){
echo 'Successfully sent';
} else {
echo 'Failed to send';
}
$to=”test@example.com";
$subject=“测试电子邮件”;
$emailBody=“你好”;
$headers=“MIME版本:1.0”。“\r\n”;
$headers.=“内容类型:text/html;字符集=iso-8859-1”。“\r\n”;
$headers.=“发件人:测试”。“\r\n”;
$headers.=“回复:否-reply@example.com“\r\n”;
$mail=mail($to、$subject、$emailBody、$headers);
如果($邮件){
echo“成功发送”;
}否则{
echo“发送失败”;
}
注意:我已将所有到地址替换为原始地址。来自PHP函数页
注:
在新的一天,邮件在网络上的路由可能不同,行为也可能不同。作为最后手段,尝试更改代码
If messages are not received, try using a LF (\n) only.
Some Unix mail transfer agents (most notably » qmail) replace LF by CRLF
automatically (which leads to doubling CR if CRLF is used).
This should be a last resort, as it does not comply with » RFC 2822.