Can't send email from PHP
Posted: Wed Jun 02, 2010 12:12 pm
I am trying to send email from my PHP page but I am having some issues.
on localhost I use apache and the code works fine and sends email.
on the live site the client uses IIS and the code doesn't works.
when I run the page on local I see the "success" message and receive the email. when the client runs on his server he sees the "error" message. Can anyone please explain why IIS can't send email ? The client has PEAR installed.
Thanks,
on localhost I use apache and the code works fine and sends email.
on the live site the client uses IIS and the code doesn't works.
Code: Select all
ini_set("display_warnings","1");
ini_set("display_errors","1");
include "Mail.php";
echo 'trying to send email....<br><br>';
$from = "from@domain.com";
$to = "to@domain.com";
$subject = "Hi!";
$body = "This is a test message !";
$host = "mail.domain.com";
$username = "username";
$password = "password";
$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 'Error';
}
else {
echo 'Success';
}
Thanks,