By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,364 Members | 1,596 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,364 IT Pros & Developers. It's quick & easy.

Send mail using php

P: 250
I want to send mail when user click "forgot password " button. This is my code and It doesn't send a mail. Could somebody tell me what is wrong with my code?

require_once "Mail.php";

$from = "test Sender <__MUNGED__>";
$to = "test Recipient <__MUNGED__>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "";
$username = "nadeeka";
$password = "__MUNGED__";

$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>");
Aug 7 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 5,058

Are you getting any errors?
If not, try turning on the debug messages and see if that helps any.

Alternatively, you could try using one of the mailer classes, like PHPMailer.
Aug 7 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.