Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

expand php mail function to include smtp authentication..

Posted on 2011-03-01
3
Medium Priority
?
323 Views
Last Modified: 2012-05-11
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
Comment
Question by:eggster34
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
psimation earned 2000 total points
ID: 35014372
I would suggest to rather use PHPMailer - has all of the functionality you want.

examples: phpmailer.worxware.com/
download: sourceforge.net/projects/phpmailer/
0
 

Author Comment

by:eggster34
ID: 35016810
I'm afraid I need to expand this specific function rather than using php mailer :(
0
 
LVL 17

Expert Comment

by:psimation
ID: 35017825
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question