mail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
madu
Forum Commoner
Posts: 32
Joined: Sat Dec 25, 2010 3:19 am
Location: india

mail

Post 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>");
}
?>
User avatar
spedula
Forum Commoner
Posts: 81
Joined: Mon Mar 29, 2010 5:24 pm

Re: mail

Post 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:
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: mail

Post by Jade »

First, do you have PEAR installed? If so take a look at this:

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