Re: [PHP] PHP SMTP Mailers

[email protected] ("Michael A. Peters")
Newsgroups php.general
Message-ID <[email protected]>
King Coffee wrote:
> Hi,
> 
> I'm executing a third-parity standard PHP application on a Windows IIS 7 
> shared hosting server.
> 
> I need to convert, or use, a SMTP mailer service.  I found two SMTP PHP 
> scripts - I think may work.
> 
> The sourceforge.net PHPMailer project and the pear.php.net (Mail, 
> Net_SMTP) project.
> 
> Can any body please help me choose one and probably give a code snip of 
> useage?
> 
> Currently, I'm leaning forward the PHPMailer, with little to base the 
> decision on.
> 
> Thanks in advanced,
> King Coffee
> 

I use phpmailer and find it to be painless and consistent.

I extend the class and call the extended class:

<?php
require("class.phpmailer.php");

class MyMailer extends PHPMailer {
     // Set default variables for all new objects
     var $From     = "[email protected]";
     var $FromName = "Lampro P. Eltis";
     var $ReplyTo  = "[email protected]";
     var $Host     = "localhost";
     var $Mailer   = "smtp";      // Alternative to IsSMTP()
     var $WordWrap = 75;
}
?>

Then when I want to use it -

$mail = new MyMailer();
$mail->Subject  = "Some Subject";
$mail->Body = "Some content";
if($mail->Send()) {
    // it was successfully sent, code on success here
    } else {
    // there was an error, error code here
    }

I never send HTML mail or attachments or bulk mail, but I believe it is 
capable of doing them quite easily.

Tip: Whatever solution you use, set the wordwrap to something that works 
well on an 80 char display. Some clients do not autowrap unwrapped 
messages and other clients wrap for display but when replying, it 
doesn't wrap.

I use 75 because it gives a little room for the "> " that accompanies a 
reply.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.