Link to home
Start Free TrialLog in
Avatar of eggster34
eggster34

asked on

expand php mail function to include smtp authentication..

Hi, I have a php mail function created by someone else, which works great.

I just want to add smtp authentication to this; how can I expand my function so that I could specify an smtp host, smtp authentication, an smtp username and pass?

thanks.

<?php
 
class simple_mail{
 var $to;
 var $from;  
 var $subject;
 var $body;
 var $html;
 
 function simple_mail(){  
  $this->to   = "";
  $this->from  = "";  
  $this->subject = "";
  $this->body  = "";
  $this->html  = 0;
 }
 
 function send(){
 
  if($this->html == 1)
  {
         $headers  = "MIME-Version: 1.0\r\n";
       $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
  }
 
  $headers .= "From: ".$this->from."\r\n";
 
  if(@mail($this->to, $this->subject, $this->body, $headers)!= 1)
            return false;
  else
   return true;
}
}
?>
ASKER CERTIFIED SOLUTION
Avatar of psimation
psimation
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eggster34
eggster34

ASKER

I'm afraid I need to expand this specific function rather than using php mailer :(
the basic mail() function in php does not have comprehensive options. It basically just uses the underlying mailer program configured in your php.ini file.

You can send some command line options to the underlying mailer program using mail(), but I've never seen an example of sending smtp auth info this way.