[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

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;
}
}
?>
0
eggster34
Asked:
eggster34
  • 2
1 Solution
 
psimationCommented:
I would suggest to rather use PHPMailer - has all of the functionality you want.

examples: phpmailer.worxware.com/
download: sourceforge.net/projects/phpmailer/
0
 
eggster34Author Commented:
I'm afraid I need to expand this specific function rather than using php mailer :(
0
 
psimationCommented:
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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now