【问题标题】:php mail not working on rackspace cloudphp邮件在机架空间云上不起作用
【发布时间】:2012-03-28 16:25:20
【问题描述】:

我有这个机架空间服务器,我在那里安装了 sendmail。 sendmail 配置为使用 sendgrid 发送电子邮件。

所以 sendmail 通过终端工作,但是 php mail 函数返回 false,并且不发送任何电子邮件。 sendmail 路径也在 php.ini 中正确设置。

我在 /etc/php.ini 中有这个,

sendmail_path = /usr/sbin/sendmail

当我使用 phpinfo() 时

<?php

phpinfo()

返回

sendmail_path = /usr/sbin/sendmail 

【问题讨论】:

  • 两个快速的想法:重新加载配置文件并仔细检查您的权限
  • 权限到底是什么权限?
  • 验证您正在使用正在编辑的php.ini,当phpinfo() 显示时,检查php.ini 是否显示为/etc/php.ini。如果做不到这一点,这个问题可能会在 serverfault.com 上得到更多答案
  • 已验证,它使用的是正确的

标签: sendmail php


【解决方案1】:

来自http://www.rackspace.com/knowledge_center/article/how-do-i-test-php-smtp-functionality,这里是他们引用的代码,用于让您的邮件在 Rackspace 云站点上运行...

非 SSL

<?php
require_once "Mail.php";


$from = "Web Master <webmaster@example.com>";
$to = "Nobody <nobody@example.com>";
$subject = "Test email using PHP SMTP\r\n\r\n";
$body = "This is a test email message";

$host = "mail.emailsrvr.com";
$username = "webmaster@example.com";
$password = "yourPassword";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
  echo("<p>Message successfully sent!</p>");
}

使用 SSL

<?php
require_once "Mail.php";

$from = "Web Master <webmaster@example.com>";
$to = "Nobody <nobody@example.com>";
$subject = "Test email using PHP SMTP with SSL\r\n\r\n";
$body = "This is a test email message";

$host = "ssl://secure.emailsrvr.com";
$port = "465";
$username = "webmaster@example.com";
$password = "yourPassword";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'port' => $port,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
  echo("<p>Message successfully sent!</p>");
}
?>

相关问题

php mail function not sending emails / taking too long to send emails

他们也在这里提出了一些问题。

http://www.joshuawinn.com/huge-email-delays-on-rackspace-cloud-sites-dont-use-php-mail

【讨论】:

  • 虽然理论上这可以回答问题,但我们希望您在回答中包含链接文章的基本部分,并提供link for reference。如果不这样做,答案就会面临链接失效的风险。
  • 抱歉,Kev,我已经更新了我的帖子以反映您的要求。
猜你喜欢
  • 1970-01-01
  • 2013-05-22
  • 1970-01-01
  • 1970-01-01
  • 2019-11-17
  • 1970-01-01
  • 2014-09-04
  • 1970-01-01
  • 2013-01-14
相关资源
最近更新 更多