Home | Affiliates | Testimonials | Client Login FAQ Payment Options


Register Domain Name from Rs.285 only:
 
   
 

Hosting.India.to
Please Login or Register

Knowledgebase

PHP send mail with SMTP Authentication

<?php

require_once "Mail.php";

 

$from = "XXXXXX@yourDOMAIN.com";

$to = "XXXXXXX@gmail.com";

$subject = "Hi!";

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

 

$host = "Localhost";

$username = "XXXXXXXX@yourDOMAIN.com";

$password = "XXXXXXXXX";

 

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

 }

?>



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read

Language:

Quick Navigation

Client Login

Email

Password

Remember Me

Search