php邮件不在rackspace云上工作

时间:2012-03-12 09:07:45

标签: sendmail php

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

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

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

sendmail_path = /usr/sbin/sendmail

当我使用

取一个phpinfo()时
<?php

phpinfo()

它返回

sendmail_path = /usr/sbin/sendmail 

1 个答案:

答案 0 :(得分:2)

http://www.rackspace.com/knowledge_center/article/how-do-i-test-php-smtp-functionality这里是他们引用的代码,以便让您的邮件在Rackspace Cloud Sites上运行...

<强>非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