Jump to content

How to send email using smtp authentication?


uluru75

Recommended Posts

Hi,

 

I have the code:

 

$from = "Sandra Sender <[email protected]>";

$to = "Ramona Recipient <[email protected]>";

$subject = "Hi!";

$body = "Hi,\n\nHow are you?";

 

$host = "smtp.mysite.com";

$username = "myusername";

$password = "123456";

 

$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>");

}

 

 

So, first i get this error:

Fatal error: Class 'Mail' not found in ....

 

Whenever i include "require_once 'Mail.php';"

then it is not found, which make sense.

 

what should i do to be able to send emails?

How can i get a source code of Mail.php unless is not needed.

 

Thanks,

Hi.  I am new to php so excuse me if my answer isn't that helpful, but it looks to me like this line: 

 

$smtp = Mail::factory

 

is invoking a particular Mail class that your script doesn't have access to.  The rest of the code mentions PEAR, so maybe the script is making use of component code and these guys: 

 

http://pear.php.net/

 

will be able to help you. 

 

Rgds

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.