Jump to content

Sending Mail With Authentication Details


npashitha

Recommended Posts

Hi

 

I want to send mail wih authentication details.I used th script below

 

<?php

 

if(isset($_POST['submit'])){

require_once "Mail.php";

 

 

$from = "Info <[email protected]>";

$to = "Ash <[email protected]>";

$subject = "Test email using PHP SMTP\r\n\r\n";

$body = "This is a test email message";

 

$host = "mail.domainname.com";

$username = "[email protected]";

$password = "xxxxxx";

$port =25;

$headers = array ('From' => $from,

'To' => $to,

'Subject' => $subject);

$smtp = Mail::factory('smtp',

array ('host' => $host,'port' => $port,

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

}

}

?>

PEAR module is already installed in the server.I am getting an error like

 

Fatal error: Call to undefined method PEAR_Error::send().

 

Any suggestions?

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.