2

i have this rackspace server, and i installed sendmail there. the sendmail is configured to send emails using sendgrid.

so the sendmail works via the terminal, but the php mail function returns false, and doesnt send any emails. the sendmail path is correctly set in the php.ini too.

I have this in the /etc/php.ini,

sendmail_path = /usr/sbin/sendmail

when i take a phpinfo() using

<?php

phpinfo()

it returns

sendmail_path = /usr/sbin/sendmail 
PeeHaa
  • 71,436
  • 58
  • 190
  • 262
nivanka
  • 1,352
  • 6
  • 23
  • 36

1 Answers1

3

From http://www.rackspace.com/knowledge_center/article/how-do-i-test-php-smtp-functionality here's the code they refer to use in order to get your mails working on the Rackspace Cloud Sites...

Non-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>");
}

With 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>");
}
?>

Relevant Question

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

Also over here they suggest some of what the issue is.

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

Community
  • 1
  • 1
Xedecimal
  • 3,153
  • 1
  • 19
  • 22
  • Whilst this may theoretically answer the question, we would like you to include the essential parts of the linked article in your answer, and provide the [link for reference](http://meta.stackexchange.com/q/8259). Failing to do that leaves the answer at risk from link rot. – Kev Feb 25 '13 at 20:04
  • Sorry Kev, I've updated my post to reflect what you requested. – Xedecimal Mar 01 '13 at 22:20