| 
      1
     | 
    
      PHPMailer
 
     | 
  
  
    | 
      2
     | 
    
      Full Featured Email Transfer Class for PHP
 
     | 
  
  
    | 
      3
     | 
    
      ==========================================
 
     | 
  
  
    | 
      4
     | 
    
      
 
     | 
  
  
    | 
      5
     | 
    
      ** NOTE:
 
     | 
  
  
    | 
      6
     | 
    
      
 
     | 
  
  
    | 
      7
     | 
    
      As of November 2007, PHPMailer has a new project team headed by industry
 
     | 
  
  
    | 
      8
     | 
    
      veteran Andy Prevost (codeworxtech). The first release in more than two
 
     | 
  
  
    | 
      9
     | 
    
      years will focus on fixes, adding ease-of-use enhancements, provide
 
     | 
  
  
    | 
      10
     | 
    
      basic compatibility with PHP4 and PHP5 using PHP5 backwards compatibility
 
     | 
  
  
    | 
      11
     | 
    
      features. A new release is planned before year-end 2007 that will provide
 
     | 
  
  
    | 
      12
     | 
    
      full compatiblity with PHP4 and PHP5, as well as more bug fixes.
 
     | 
  
  
    | 
      13
     | 
    
      
 
     | 
  
  
    | 
      14
     | 
    
      We are looking for project developers to assist in restoring PHPMailer to
 
     | 
  
  
    | 
      15
     | 
    
      its leadership position. Our goals are to simplify use of PHPMailer, provide
 
     | 
  
  
    | 
      16
     | 
    
      good documentation and examples, and retain backward compatibility to level
 
     | 
  
  
    | 
      17
     | 
    
      1.7.3 standards.
 
     | 
  
  
    | 
      18
     | 
    
      
 
     | 
  
  
    | 
      19
     | 
    
      If you are interested in helping out, visit http://sourceforge.net/phpmailer 
 
     | 
  
  
    | 
      20
     | 
    
      and indicate your interest.
 
     | 
  
  
    | 
      21
     | 
    
      
 
     | 
  
  
    | 
      22
     | 
    
      **
 
     | 
  
  
    | 
      23
     | 
    
      
 
     | 
  
  
    | 
      24
     | 
    
      http://phpmailer.sourceforge.net/
 
     | 
  
  
    | 
      25
     | 
    
      
 
     | 
  
  
    | 
      26
     | 
    
      This software is licenced under the LGPL.  Please read LICENSE for information on the
 
     | 
  
  
    | 
      27
     | 
    
      software availability and distribution.
 
     | 
  
  
    | 
      28
     | 
    
      
 
     | 
  
  
    | 
      29
     | 
    
      Class Features:
 
     | 
  
  
    | 
      30
     | 
    
      - Send emails with multiple TOs, CCs, BCCs and REPLY-TOs
 
     | 
  
  
    | 
      31
     | 
    
      - Redundant SMTP servers
 
     | 
  
  
    | 
      32
     | 
    
      - Multipart/alternative emails for mail clients that do not read HTML email
 
     | 
  
  
    | 
      33
     | 
    
      - Support for 8bit, base64, binary, and quoted-printable encoding
 
     | 
  
  
    | 
      34
     | 
    
      - Uses the same methods as the very popular AspEmail active server (COM) component
 
     | 
  
  
    | 
      35
     | 
    
      - SMTP authentication
 
     | 
  
  
    | 
      36
     | 
    
      - Native language support
 
     | 
  
  
    | 
      37
     | 
    
      - Word wrap, and more!
 
     | 
  
  
    | 
      38
     | 
    
      
 
     | 
  
  
    | 
      39
     | 
    
      Why you might need it:
 
     | 
  
  
    | 
      40
     | 
    
      
 
     | 
  
  
    | 
      41
     | 
    
      Many PHP developers utilize email in their code.  The only PHP function
 
     | 
  
  
    | 
      42
     | 
    
      that supports this is the mail() function.  However, it does not expose
 
     | 
  
  
    | 
      43
     | 
    
      any of the popular features that many email clients use nowadays like
 
     | 
  
  
    | 
      44
     | 
    
      HTML-based emails and attachments. There are two proprietary
 
     | 
  
  
    | 
      45
     | 
    
      development tools out there that have all the functionality built into
 
     | 
  
  
    | 
      46
     | 
    
      easy to use classes: AspEmail(tm) and AspMail.  Both of these
 
     | 
  
  
    | 
      47
     | 
    
      programs are COM components only available on Windows.  They are also a
 
     | 
  
  
    | 
      48
     | 
    
      little pricey for smaller projects.
 
     | 
  
  
    | 
      49
     | 
    
      
 
     | 
  
  
    | 
      50
     | 
    
      Since I do Linux development I?ve missed these tools for my PHP coding.
 
     | 
  
  
    | 
      51
     | 
    
      So I built a version myself that implements the same methods (object
 
     | 
  
  
    | 
      52
     | 
    
      calls) that the Windows-based components do. It is open source and the
 
     | 
  
  
    | 
      53
     | 
    
      LGPL license allows you to place the class in your proprietary PHP
 
     | 
  
  
    | 
      54
     | 
    
      projects.
 
     | 
  
  
    | 
      55
     | 
    
      
 
     | 
  
  
    | 
      56
     | 
    
      
 
     | 
  
  
    | 
      57
     | 
    
      Installation:
 
     | 
  
  
    | 
      58
     | 
    
      
 
     | 
  
  
    | 
      59
     | 
    
      Copy class.phpmailer.php into your php.ini include_path. If you are
 
     | 
  
  
    | 
      60
     | 
    
      using the SMTP mailer then place class.smtp.php in your path as well.
 
     | 
  
  
    | 
      61
     | 
    
      In the language directory you will find several files like 
 
     | 
  
  
    | 
      62
     | 
    
      phpmailer.lang-en.php.  If you look right before the .php extension 
 
     | 
  
  
    | 
      63
     | 
    
      that there are two letters.  These represent the language type of the 
 
     | 
  
  
    | 
      64
     | 
    
      translation file.  For instance "en" is the English file and "br" is 
 
     | 
  
  
    | 
      65
     | 
    
      the Portuguese file.  Chose the file that best fits with your language 
 
     | 
  
  
    | 
      66
     | 
    
      and place it in the PHP include path.  If your language is English 
 
     | 
  
  
    | 
      67
     | 
    
      then you have nothing more to do.  If it is a different language then 
 
     | 
  
  
    | 
      68
     | 
    
      you must point PHPMailer to the correct translation.  To do this, call 
 
     | 
  
  
    | 
      69
     | 
    
      the PHPMailer SetLanguage method like so:
 
     | 
  
  
    | 
      70
     | 
    
      
 
     | 
  
  
    | 
      71
     | 
    
      // To load the Portuguese version
 
     | 
  
  
    | 
      72
     | 
    
      $mail->SetLanguage("br", "/optional/path/to/language/directory/");
     | 
  
  
    | 
      73
     | 
    
      
 
     | 
  
  
    | 
      74
     | 
    
      That's it.  You should now be ready to use PHPMailer!
 
     | 
  
  
    | 
      75
     | 
    
      
 
     | 
  
  
    | 
      76
     | 
    
      
 
     | 
  
  
    | 
      77
     | 
    
      A Simple Example:
 
     | 
  
  
    | 
      78
     | 
    
      
 
     | 
  
  
    | 
      79
     | 
    
      <?php
 
     | 
  
  
    | 
      80
     | 
    
      require("class.phpmailer.php");
     | 
  
  
    | 
      81
     | 
    
      
 
     | 
  
  
    | 
      82
     | 
    
      $mail = new PHPMailer();
 
     | 
  
  
    | 
      83
     | 
    
      
 
     | 
  
  
    | 
      84
     | 
    
      $mail->IsSMTP();                                      // set mailer to use SMTP
 
     | 
  
  
    | 
      85
     | 
    
      $mail->Host = "smtp1.example.com;smtp2.example.com";  // specify main and backup server
 
     | 
  
  
    | 
      86
     | 
    
      $mail->SMTPAuth = true;     // turn on SMTP authentication
 
     | 
  
  
    | 
      87
     | 
    
      $mail->Username = "jswan";  // SMTP username
 
     | 
  
  
    | 
      88
     | 
    
      $mail->Password = "secret"; // SMTP password
 
     | 
  
  
    | 
      89
     | 
    
      
 
     | 
  
  
    | 
      90
     | 
    
      $mail->From = "from@example.com";
 
     | 
  
  
    | 
      91
     | 
    
      $mail->FromName = "Mailer";
 
     | 
  
  
    | 
      92
     | 
    
      $mail->AddAddress("josh@example.net", "Josh Adams");
     | 
  
  
    | 
      93
     | 
    
      $mail->AddAddress("ellen@example.com");                  // name is optional
     | 
  
  
    | 
      94
     | 
    
      $mail->AddReplyTo("info@example.com", "Information");
     | 
  
  
    | 
      95
     | 
    
      
 
     | 
  
  
    | 
      96
     | 
    
      $mail->WordWrap = 50;                                 // set word wrap to 50 characters
 
     | 
  
  
    | 
      97
     | 
    
      $mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
     | 
  
  
    | 
      98
     | 
    
      $mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
     | 
  
  
    | 
      99
     | 
    
      $mail->IsHTML(true);                                  // set email format to HTML
 
     | 
  
  
    | 
      100
     | 
    
      
 
     | 
  
  
    | 
      101
     | 
    
      $mail->Subject = "Here is the subject";
 
     | 
  
  
    | 
      102
     | 
    
      $mail->Body    = "This is the HTML message body <b>in bold!</b>";
 
     | 
  
  
    | 
      103
     | 
    
      $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
 
     | 
  
  
    | 
      104
     | 
    
      
 
     | 
  
  
    | 
      105
     | 
    
      if(!$mail->Send())
 
     | 
  
  
    | 
      106
     | 
    
      {
     | 
  
  
    | 
      107
     | 
    
         echo "Message could not be sent. <p>";
 
     | 
  
  
    | 
      108
     | 
    
         echo "Mailer Error: " . $mail->ErrorInfo;
 
     | 
  
  
    | 
      109
     | 
    
         exit;
 
     | 
  
  
    | 
      110
     | 
    
      }
 
     | 
  
  
    | 
      111
     | 
    
      
 
     | 
  
  
    | 
      112
     | 
    
      echo "Message has been sent";
 
     | 
  
  
    | 
      113
     | 
    
      ?>
 
     | 
  
  
    | 
      114
     | 
    
      
 
     | 
  
  
    | 
      115
     | 
    
      CHANGELOG
 
     | 
  
  
    | 
      116
     | 
    
      
 
     | 
  
  
    | 
      117
     | 
    
      See ChangeLog.txt
 
     | 
  
  
    | 
      118
     | 
    
      
 
     | 
  
  
    | 
      119
     | 
    
      Download: http://sourceforge.net/project/showfiles.php?group_id=26031
 
     | 
  
  
    | 
      120
     | 
    
      
 
     | 
  
  
    | 
      121
     | 
    
      Andy Prevost
 
     |