我目前在工作中使用定制的库.直到这个图书馆工作得非常好.从今天开始,它显然是假的.
库本身它基本上是函数邮件的包装器.它构建了"边界"部分和一切.
由于课程相当大,我不会在这里发布...但我想知道,理论上为什么邮件会返回错误的原因是什么?
sender<sender@email.com>[编辑]刚刚找到一个较小的功能,仍然无法正常工作,我会打印出来然后:
function send_html($from, $email, $subject = "AUCUN", $message, $cc = "", $bcc ="", $priotity = "3") {
$headers = "";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
if (strpos($from, "ourwebsite.com") != false || strpos($from, "rencontresportive.com") != "") {
$headers .= "From: Ourwebsite.com <" . $from . ">\r\n";
} else {
$headers .= "From: " . $from . " <" . $from . ">\r\n";
}
$headers .= "X-Sender: <" . $from . ">\r\n";
$headers .= "X-Priority: " . $priotity . "\r\n";
$headers .= "X-Mailer: PHP\r\n";
$headers .= "Return-Path: <admin@ourwebsite.com>\r\n";
if ($cc != "") {
$headers .= "cc:" . $cc . "\r\n";
}
if ($bcc != "") {
$headers .= "bcc:" . $bcc . "\r\n";
}
if (mail($email, $subject, $message, $headers)) {
return true;
} else {
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我叫它:
send_html(contact@ourwebsite.com, me@me.com, utf8_decode("the subject"), "<h1>test</h1>");
Run Code Online (Sandbox Code Playgroud)
txy*_*oji 16
我刚遇到同样的问题.在php升级之后,mail函数总是返回false.
我用这个小片段来检查出来:
<?php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 1);
echo 'I am : ' . `whoami`;
$result = mail('myaddress@mydomain.com','Testing 1 2 3','This is a test.');
echo '<hr>Result was: ' . ( $result === FALSE ? 'FALSE' : 'TRUE') . $result;
echo '<hr>';
echo phpinfo();
Run Code Online (Sandbox Code Playgroud)
解决方案是在我的php.ini中为'sendmail_from'和'sendmail_path'设置一个值.我的案例中的正确值是:
sendmail_from = "no-reply@mydomain.net"
sendmail_path = "/usr/sbin/sendmail -t -i"
Run Code Online (Sandbox Code Playgroud)
(我使用的是带有Zend Server CE的CentOS 5.3.)
您可以使用ini_set()来设置'sendmail_from'的值,但必须在php.ini或http.conf中设置'sendmail_path'var.
小智 6
我有类似的问题,即使成功收到电子邮件,邮件功能也总是返回false.
我在php配置文件php.ini中找到了,我已经设置好了
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only.
sendmail_path = "/usr/sbin/sendmail -t -i -f "care@mydomain.com"
Run Code Online (Sandbox Code Playgroud)
我把它改成了下面
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only.
sendmail_path = /usr/sbin/sendmail -t -i -f care@mydomain.com
Run Code Online (Sandbox Code Playgroud)
根据这个,sendmail_from是针对win32的,所以在*unix OS中我们需要设置sendmail_path变量中显示的值.
关心Minesh
| 归档时间: |
|
| 查看次数: |
39161 次 |
| 最近记录: |