Page 1 of 1

mail

Posted: Thu Jan 06, 2011 5:01 am
by madu
hi friends,,,
i am trying to send mail from my local host,,,i am using mamp server and mac os ,,,,no error display,,,,but mail not send,,,,
<?php
$host = "smtp.gmail.com";
$username = "easwarsait@gmail.com;
$password = "my mail password";
$FromName = "suresh";
$FromEmail = "msuresh4549@gmail.com";
$ToName = "my friend";
$ToEmail = "karuda74@yahoo.com";
$subject = "hi ,,,,hi";
$body = "sdfds dg dfgfgh fgj fgj ghjj gjgh jghkhgk gjghjhgjgh ";
$from = "suresh<easwarsait@gmail.com>"; // Provide your name and your email address
$to = "balu<karuda74@yahoo.com>";
$headers = array ('From' => $from,'To' => $to,'Subject' => $subject);
$smtp = Mail::factory('smtp',array ('host' => $host,'auth' => true,'username' => $username,'password' => $password)) or die("error in smtp con");
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
}else{
echo("<p>Message successfully sent!</p>");
}
?>

Re: mail

Posted: Thu Jan 06, 2011 12:23 pm
by spedula
If this is your whole code then it looks like you're missing something.

I can see that you're calling the function send, which belongs to the object $smpt, but this object was never created in the script so no mail() function for that object can be defined or used.

Try a different tutorial, preferably one that doesn't use OOP. :wink:

Re: mail

Posted: Thu Jan 06, 2011 12:31 pm
by Jade
First, do you have PEAR installed? If so take a look at this:

http://stackoverflow.com/questions/7123 ... m-php-page