Project

General

Profile

« Previous | Next » 

Revision 2053

Added by darkviper almost 11 years ago

! update PHPMailer to version Version 5.2.7

View differences:

class.phpmailer.php
1 1
<?php
2
/*~ class.phpmailer.php
3
.---------------------------------------------------------------------------.
4
|  Software: PHPMailer - PHP email class                                    |
5
|   Version: 5.2.1                                                          |
6
|      Site: https://code.google.com/a/apache-extras.org/p/phpmailer/       |
7
| ------------------------------------------------------------------------- |
8
|     Admin: Jim Jagielski (project admininistrator)                        |
9
|   Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
10
|          : Marcus Bointon (coolbru) coolbru@users.sourceforge.net         |
11
|          : Jim Jagielski (jimjag) jimjag@gmail.com                        |
12
|   Founder: Brent R. Matzelle (original founder)                           |
13
| Copyright (c) 2010-2012, Jim Jagielski. All Rights Reserved.              |
14
| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved.               |
15
| Copyright (c) 2001-2003, Brent R. Matzelle                                |
16
| ------------------------------------------------------------------------- |
17
|   License: Distributed under the Lesser General Public License (LGPL)     |
18
|            http://www.gnu.org/copyleft/lesser.html                        |
19
| This program is distributed in the hope that it will be useful - WITHOUT  |
20
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     |
21
| FITNESS FOR A PARTICULAR PURPOSE.                                         |
22
'---------------------------------------------------------------------------'
23
*/
24

  
25 2
/**
26
 * PHPMailer - PHP email transport class
27
 * NOTE: Requires PHP version 5 or later
3
 * PHPMailer - PHP email creation and transport class.
4
 * PHP Version 5.0.0
5
 * Version 5.2.7
28 6
 * @package PHPMailer
29
 * @author Andy Prevost
30
 * @author Marcus Bointon
31
 * @author Jim Jagielski
7
 * @link https://github.com/PHPMailer/PHPMailer/
8
 * @author Marcus Bointon (coolbru) <phpmailer@synchromedia.co.uk>
9
 * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
10
 * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
11
 * @author Brent R. Matzelle (original founder)
12
 * @copyright 2013 Marcus Bointon
32 13
 * @copyright 2010 - 2012 Jim Jagielski
33 14
 * @copyright 2004 - 2009 Andy Prevost
34
 * @version $Id: class.phpmailer.php 450 2010-06-23 16:46:33Z coolbru $
35 15
 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
16
 * @note This program is distributed in the hope that it will be useful - WITHOUT
17
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
 * FITNESS FOR A PARTICULAR PURPOSE.
36 19
 */
37 20

  
38
if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
21
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
22
    exit("Sorry, PHPMailer will only run on PHP version 5 or greater!\n");
23
}
39 24

  
40
class PHPMailer {
25
/**
26
 * PHPMailer - PHP email creation and transport class.
27
 * PHP Version 5.0.0
28
 * @package PHPMailer
29
 * @author Marcus Bointon (coolbru) <phpmailer@synchromedia.co.uk>
30
 * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
31
 * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
32
 * @author Brent R. Matzelle (original founder)
33
 * @copyright 2013 Marcus Bointon
34
 * @copyright 2010 - 2012 Jim Jagielski
35
 * @copyright 2004 - 2009 Andy Prevost
36
 */
37
class PHPMailer
38
{
39
    /**
40
     * The PHPMailer Version number.
41
     * @type string
42
     */
43
    public $Version = '5.2.7';
41 44

  
42
  /////////////////////////////////////////////////
43
  // PROPERTIES, PUBLIC
44
  /////////////////////////////////////////////////
45
    /**
46
     * Email priority.
47
     * Options: 1 = High, 3 = Normal, 5 = low.
48
     * @type int
49
     */
50
    public $Priority = 3;
45 51

  
46
  /**
47
   * Email priority (1 = High, 3 = Normal, 5 = low).
48
   * @var int
49
   */
50
  public $Priority          = 3;
52
    /**
53
     * The character set of the message.
54
     * @type string
55
     */
56
    public $CharSet = 'iso-8859-1';
51 57

  
52
  /**
53
   * Sets the CharSet of the message.
54
   * @var string
55
   */
56
  public $CharSet           = 'iso-8859-1';
58
    /**
59
     * The MIME Content-type of the message.
60
     * @type string
61
     */
62
    public $ContentType = 'text/plain';
57 63

  
58
  /**
59
   * Sets the Content-type of the message.
60
   * @var string
61
   */
62
  public $ContentType       = 'text/plain';
64
    /**
65
     * The message encoding.
66
     * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
67
     * @type string
68
     */
69
    public $Encoding = '8bit';
63 70

  
64
  /**
65
   * Sets the Encoding of the message. Options for this are
66
   *  "8bit", "7bit", "binary", "base64", and "quoted-printable".
67
   * @var string
68
   */
69
  public $Encoding          = '8bit';
71
    /**
72
     * Holds the most recent mailer error message.
73
     * @type string
74
     */
75
    public $ErrorInfo = '';
70 76

  
71
  /**
72
   * Holds the most recent mailer error message.
73
   * @var string
74
   */
75
  public $ErrorInfo         = '';
77
    /**
78
     * The From email address for the message.
79
     * @type string
80
     */
81
    public $From = 'root@localhost';
76 82

  
77
  /**
78
   * Sets the From email address for the message.
79
   * @var string
80
   */
81
  public $From              = 'root@localhost';
83
    /**
84
     * The From name of the message.
85
     * @type string
86
     */
87
    public $FromName = 'Root User';
82 88

  
83
  /**
84
   * Sets the From name of the message.
85
   * @var string
86
   */
87
  public $FromName          = 'Root User';
89
    /**
90
     * The Sender email (Return-Path) of the message.
91
     * If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
92
     * @type string
93
     */
94
    public $Sender = '';
88 95

  
89
  /**
90
   * Sets the Sender email (Return-Path) of the message.  If not empty,
91
   * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
92
   * @var string
93
   */
94
  public $Sender            = '';
96
    /**
97
     * The Return-Path of the message.
98
     * If empty, it will be set to either From or Sender.
99
     * @type string
100
     */
101
    public $ReturnPath = '';
95 102

  
96
  /**
97
   * Sets the Subject of the message.
98
   * @var string
99
   */
100
  public $Subject           = '';
103
    /**
104
     * The Subject of the message.
105
     * @type string
106
     */
107
    public $Subject = '';
101 108

  
102
  /**
103
   * Sets the Body of the message.  This can be either an HTML or text body.
104
   * If HTML then run IsHTML(true).
105
   * @var string
106
   */
107
  public $Body              = '';
109
    /**
110
     * An HTML or plain text message body.
111
     * If HTML then call isHTML(true).
112
     * @type string
113
     */
114
    public $Body = '';
108 115

  
109
  /**
110
   * Sets the text-only body of the message.  This automatically sets the
111
   * email to multipart/alternative.  This body can be read by mail
112
   * clients that do not have HTML email capability such as mutt. Clients
113
   * that can read HTML will view the normal Body.
114
   * @var string
115
   */
116
  public $AltBody           = '';
116
    /**
117
     * The plain-text message body.
118
     * This body can be read by mail clients that do not have HTML email
119
     * capability such as mutt & Eudora.
120
     * Clients that can read HTML will view the normal Body.
121
     * @type string
122
     */
123
    public $AltBody = '';
117 124

  
118
  /**
119
   * Stores the complete compiled MIME message body.
120
   * @var string
121
   * @access protected
122
   */
123
  protected $MIMEBody       = '';
125
    /**
126
     * An iCal message part body.
127
     * Only supported in simple alt or alt_inline message types
128
     * To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator
129
     * @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
130
     * @link http://kigkonsult.se/iCalcreator/
131
     * @type string
132
     */
133
    public $Ical = '';
124 134

  
125
  /**
126
   * Stores the complete compiled MIME message headers.
127
   * @var string
128
   * @access protected
129
   */
130
  protected $MIMEHeader     = '';
135
    /**
136
     * The complete compiled MIME message body.
137
     * @access protected
138
     * @type string
139
     */
140
    protected $MIMEBody = '';
131 141

  
132
  /**
133
   * Stores the complete sent MIME message (Body and Headers)
134
   * @var string
135
   * @access protected
136
  */
137
  protected $SentMIMEMessage     = '';
142
    /**
143
     * The complete compiled MIME message headers.
144
     * @type string
145
     * @access protected
146
     */
147
    protected $MIMEHeader = '';
138 148

  
139
  /**
140
   * Sets word wrapping on the body of the message to a given number of
141
   * characters.
142
   * @var int
143
   */
144
  public $WordWrap          = 0;
149
    /**
150
     * Extra headers that createHeader() doesn't fold in.
151
     * @type string
152
     * @access protected
153
     */
154
    protected $mailHeader = '';
145 155

  
146
  /**
147
   * Method to send mail: ("mail", "sendmail", or "smtp").
148
   * @var string
149
   */
150
  public $Mailer            = 'mail';
156
    /**
157
     * Word-wrap the message body to this number of chars.
158
     * @type int
159
     */
160
    public $WordWrap = 0;
151 161

  
152
  /**
153
   * Sets the path of the sendmail program.
154
   * @var string
155
   */
156
  public $Sendmail          = '/usr/sbin/sendmail';
162
    /**
163
     * Which method to use to send mail.
164
     * Options: "mail", "sendmail", or "smtp".
165
     * @type string
166
     */
167
    public $Mailer = 'mail';
157 168

  
158
  /**
159
   * Path to PHPMailer plugins.  Useful if the SMTP class
160
   * is in a different directory than the PHP include path.
161
   * @var string
162
   */
163
  public $PluginDir         = '';
169
    /**
170
     * The path to the sendmail program.
171
     * @type string
172
     */
173
    public $Sendmail = '/usr/sbin/sendmail';
164 174

  
165
  /**
166
   * Sets the email address that a reading confirmation will be sent.
167
   * @var string
168
   */
169
  public $ConfirmReadingTo  = '';
175
    /**
176
     * Whether mail() uses a fully sendmail-compatible MTA.
177
     * One which supports sendmail's "-oi -f" options.
178
     * @type bool
179
     */
180
    public $UseSendmailOptions = true;
170 181

  
171
  /**
172
   * Sets the hostname to use in Message-Id and Received headers
173
   * and as default HELO string. If empty, the value returned
174
   * by SERVER_NAME is used or 'localhost.localdomain'.
175
   * @var string
176
   */
177
  public $Hostname          = '';
182
    /**
183
     * Path to PHPMailer plugins.
184
     * Useful if the SMTP class is not in the PHP include path.
185
     * @type string
186
     * @deprecated Should not be needed now there is an autoloader.
187
     */
188
    public $PluginDir = '';
178 189

  
179
  /**
180
   * Sets the message ID to be used in the Message-Id header.
181
   * If empty, a unique id will be generated.
182
   * @var string
183
   */
184
  public $MessageID         = '';
190
    /**
191
     * The email address that a reading confirmation should be sent to.
192
     * @type string
193
     */
194
    public $ConfirmReadingTo = '';
185 195

  
186
  /////////////////////////////////////////////////
187
  // PROPERTIES FOR SMTP
188
  /////////////////////////////////////////////////
196
    /**
197
     * The hostname to use in Message-Id and Received headers
198
     * and as default HELO string.
199
     * If empty, the value returned
200
     * by SERVER_NAME is used or 'localhost.localdomain'.
201
     * @type string
202
     */
203
    public $Hostname = '';
189 204

  
190
  /**
191
   * Sets the SMTP hosts.  All hosts must be separated by a
192
   * semicolon.  You can also specify a different port
193
   * for each host by using this format: [hostname:port]
194
   * (e.g. "smtp1.example.com:25;smtp2.example.com").
195
   * Hosts will be tried in order.
196
   * @var string
197
   */
198
  public $Host          = 'localhost';
205
    /**
206
     * An ID to be used in the Message-Id header.
207
     * If empty, a unique id will be generated.
208
     * @type string
209
     */
210
    public $MessageID = '';
199 211

  
200
  /**
201
   * Sets the default SMTP server port.
202
   * @var int
203
   */
204
  public $Port          = 25;
212
    /**
213
     * The message Date to be used in the Date header.
214
     * If empty, the current date will be added.
215
     * @type string
216
     */
217
    public $MessageDate = '';
205 218

  
206
  /**
207
   * Sets the SMTP HELO of the message (Default is $Hostname).
208
   * @var string
209
   */
210
  public $Helo          = '';
219
    /**
220
     * SMTP hosts.
221
     * Either a single hostname or multiple semicolon-delimited hostnames.
222
     * You can also specify a different port
223
     * for each host by using this format: [hostname:port]
224
     * (e.g. "smtp1.example.com:25;smtp2.example.com").
225
     * Hosts will be tried in order.
226
     * @type string
227
     */
228
    public $Host = 'localhost';
211 229

  
212
  /**
213
   * Sets connection prefix.
214
   * Options are "", "ssl" or "tls"
215
   * @var string
216
   */
217
  public $SMTPSecure    = '';
230
    /**
231
     * The default SMTP server port.
232
     * @type int
233
     * @Todo Why is this needed when the SMTP class takes care of it?
234
     */
235
    public $Port = 25;
218 236

  
219
  /**
220
   * Sets SMTP authentication. Utilizes the Username and Password variables.
221
   * @var bool
222
   */
223
  public $SMTPAuth      = false;
237
    /**
238
     * The SMTP HELO of the message.
239
     * Default is $Hostname.
240
     * @type string
241
     * @see PHPMailer::$Hostname
242
     */
243
    public $Helo = '';
224 244

  
225
  /**
226
   * Sets SMTP username.
227
   * @var string
228
   */
229
  public $Username      = '';
245
    /**
246
     * The secure connection prefix.
247
     * Options: "", "ssl" or "tls"
248
     * @type string
249
     */
250
    public $SMTPSecure = '';
230 251

  
231
  /**
232
   * Sets SMTP password.
233
   * @var string
234
   */
235
  public $Password      = '';
252
    /**
253
     * Whether to use SMTP authentication.
254
     * Uses the Username and Password properties.
255
     * @type bool
256
     * @see PHPMailer::$Username
257
     * @see PHPMailer::$Password
258
     */
259
    public $SMTPAuth = false;
236 260

  
237
  /**
238
   * Sets the SMTP server timeout in seconds.
239
   * This function will not work with the win32 version.
240
   * @var int
241
   */
242
  public $Timeout       = 10;
261
    /**
262
     * SMTP username.
263
     * @type string
264
     */
265
    public $Username = '';
243 266

  
244
  /**
245
   * Sets SMTP class debugging on or off.
246
   * @var bool
247
   */
248
  public $SMTPDebug     = false;
267
    /**
268
     * SMTP password.
269
     * @type string
270
     */
271
    public $Password = '';
249 272

  
250
  /**
251
   * Prevents the SMTP connection from being closed after each mail
252
   * sending.  If this is set to true then to close the connection
253
   * requires an explicit call to SmtpClose().
254
   * @var bool
255
   */
256
  public $SMTPKeepAlive = false;
273
    /**
274
     * SMTP auth type.
275
     * Options are LOGIN (default), PLAIN, NTLM, CRAM-MD5
276
     * @type string
277
     */
278
    public $AuthType = '';
257 279

  
258
  /**
259
   * Provides the ability to have the TO field process individual
260
   * emails, instead of sending to entire TO addresses
261
   * @var bool
262
   */
263
  public $SingleTo      = false;
280
    /**
281
     * SMTP realm.
282
     * Used for NTLM auth
283
     * @type string
284
     */
285
    public $Realm = '';
264 286

  
265
   /**
266
   * If SingleTo is true, this provides the array to hold the email addresses
267
   * @var bool
268
   */
269
  public $SingleToArray = array();
287
    /**
288
     * SMTP workstation.
289
     * Used for NTLM auth
290
     * @type string
291
     */
292
    public $Workstation = '';
270 293

  
271
 /**
272
   * Provides the ability to change the line ending
273
   * @var string
274
   */
275
  public $LE              = "\n";
294
    /**
295
     * The SMTP server timeout in seconds.
296
     * @type int
297
     */
298
    public $Timeout = 10;
276 299

  
277
  /**
278
   * Used with DKIM DNS Resource Record
279
   * @var string
280
   */
281
  public $DKIM_selector   = 'phpmailer';
300
    /**
301
     * SMTP class debug output mode.
302
     * Options: 0 = off, 1 = commands, 2 = commands and data
303
     * @type int
304
     * @see SMTP::$do_debug
305
     */
306
    public $SMTPDebug = 0;
282 307

  
283
  /**
284
   * Used with DKIM DNS Resource Record
285
   * optional, in format of email address 'you@yourdomain.com'
286
   * @var string
287
   */
288
  public $DKIM_identity   = '';
308
    /**
309
     * The function/method to use for debugging output.
310
     * Options: "echo" or "error_log"
311
     * @type string
312
     * @see SMTP::$Debugoutput
313
     */
314
    public $Debugoutput = "echo";
289 315

  
290
  /**
291
   * Used with DKIM DNS Resource Record
292
   * @var string
293
   */
294
  public $DKIM_passphrase   = '';
316
    /**
317
     * Whether to keep SMTP connection open after each message.
318
     * If this is set to true then to close the connection
319
     * requires an explicit call to smtpClose().
320
     * @type bool
321
     */
322
    public $SMTPKeepAlive = false;
295 323

  
296
  /**
297
   * Used with DKIM DNS Resource Record
298
   * optional, in format of email address 'you@yourdomain.com'
299
   * @var string
300
   */
301
  public $DKIM_domain     = '';
324
    /**
325
     * Whether to split multiple to addresses into multiple messages
326
     * or send them all in one message.
327
     * @type bool
328
     */
329
    public $SingleTo = false;
302 330

  
303
  /**
304
   * Used with DKIM DNS Resource Record
305
   * optional, in format of email address 'you@yourdomain.com'
306
   * @var string
307
   */
308
  public $DKIM_private    = '';
331
    /**
332
     * Storage for addresses when SingleTo is enabled.
333
     * @type array
334
     * @todo This should really not be public
335
     */
336
    public $SingleToArray = array();
309 337

  
310
  /**
311
   * Callback Action function name
312
   * the function that handles the result of the send email action. Parameters:
313
   *   bool    $result        result of the send action
314
   *   string  $to            email address of the recipient
315
   *   string  $cc            cc email addresses
316
   *   string  $bcc           bcc email addresses
317
   *   string  $subject       the subject
318
   *   string  $body          the email body
319
   * @var string
320
   */
321
  public $action_function = ''; //'callbackAction';
338
    /**
339
     * Whether to generate VERP addresses on send.
340
     * Only applicable when sending via SMTP.
341
     * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path
342
     * @type bool
343
     */
344
    public $do_verp = false;
322 345

  
323
  /**
324
   * Sets the PHPMailer Version number
325
   * @var string
326
   */
327
  public $Version         = '5.2.1';
346
    /**
347
     * Whether to allow sending messages with an empty body.
348
     * @type bool
349
     */
350
    public $AllowEmpty = false;
328 351

  
329
  /**
330
   * What to use in the X-Mailer header
331
   * @var string
332
   */
333
  public $XMailer         = '';
352
    /**
353
     * The default line ending.
354
     * @note The default remains "\n". We force CRLF where we know
355
     *        it must be used via self::CRLF.
356
     * @type string
357
     */
358
    public $LE = "\n";
334 359

  
335
  /////////////////////////////////////////////////
336
  // PROPERTIES, PRIVATE AND PROTECTED
337
  /////////////////////////////////////////////////
360
    /**
361
     * DKIM selector.
362
     * @type string
363
     */
364
    public $DKIM_selector = '';
338 365

  
339
  protected   $smtp           = NULL;
340
  protected   $to             = array();
341
  protected   $cc             = array();
342
  protected   $bcc            = array();
343
  protected   $ReplyTo        = array();
344
  protected   $all_recipients = array();
345
  protected   $attachment     = array();
346
  protected   $CustomHeader   = array();
347
  protected   $message_type   = '';
348
  protected   $boundary       = array();
349
  protected   $language       = array();
350
  protected   $error_count    = 0;
351
  protected   $sign_cert_file = '';
352
  protected   $sign_key_file  = '';
353
  protected   $sign_key_pass  = '';
354
  protected   $exceptions     = false;
366
    /**
367
     * DKIM Identity.
368
     * Usually the email address used as the source of the email
369
     * @type string
370
     */
371
    public $DKIM_identity = '';
355 372

  
356
  /////////////////////////////////////////////////
357
  // CONSTANTS
358
  /////////////////////////////////////////////////
373
    /**
374
     * DKIM passphrase.
375
     * Used if your key is encrypted.
376
     * @type string
377
     */
378
    public $DKIM_passphrase = '';
359 379

  
360
  const STOP_MESSAGE  = 0; // message only, continue processing
361
  const STOP_CONTINUE = 1; // message?, likely ok to continue processing
362
  const STOP_CRITICAL = 2; // message, plus full stop, critical error reached
380
    /**
381
     * DKIM signing domain name.
382
     * @example 'example.com'
383
     * @type string
384
     */
385
    public $DKIM_domain = '';
363 386

  
364
  /////////////////////////////////////////////////
365
  // METHODS, VARIABLES
366
  /////////////////////////////////////////////////
387
    /**
388
     * DKIM private key file path.
389
     * @type string
390
     */
391
    public $DKIM_private = '';
367 392

  
368
  /**
369
   * Constructor
370
   * @param boolean $exceptions Should we throw external exceptions?
371
   */
372
  public function __construct($exceptions = false) {
373
    $this->exceptions = ($exceptions == true);
374
  }
393
    /**
394
     * Callback Action function name.
395
     *
396
     * The function that handles the result of the send email action.
397
     * It is called out by send() for each email sent.
398
     *
399
     * Value can be:
400
     * - 'function_name' for function names
401
     * - 'Class::Method' for static method calls
402
     * - array($object, 'Method') for calling methods on $object
403
     * See http://php.net/is_callable manual page for more details.
404
     *
405
     * Parameters:
406
     *   bool    $result        result of the send action
407
     *   string  $to            email address of the recipient
408
     *   string  $cc            cc email addresses
409
     *   string  $bcc           bcc email addresses
410
     *   string  $subject       the subject
411
     *   string  $body          the email body
412
     *   string  $from          email address of sender
413
     * 
414
     * @type string
415
     */
416
    public $action_function = '';
375 417

  
376
  /**
377
   * Sets message type to HTML.
378
   * @param bool $ishtml
379
   * @return void
380
   */
381
  public function IsHTML($ishtml = true) {
382
    if ($ishtml) {
383
      $this->ContentType = 'text/html';
384
    } else {
385
      $this->ContentType = 'text/plain';
386
    }
387
  }
418
    /**
419
     * What to use in the X-Mailer header.
420
     * Options: null for default, whitespace for none, or a string to use
421
     * @type string
422
     */
423
    public $XMailer = '';
388 424

  
389
  /**
390
   * Sets Mailer to send message using SMTP.
391
   * @return void
392
   */
393
  public function IsSMTP() {
394
    $this->Mailer = 'smtp';
395
  }
425
    /**
426
     * An instance of the SMTP sender class.
427
     * @type SMTP
428
     * @access protected
429
     */
430
    protected $smtp = null;
396 431

  
397
  /**
398
   * Sets Mailer to send message using PHP mail() function.
399
   * @return void
400
   */
401
  public function IsMail() {
402
    $this->Mailer = 'mail';
403
  }
432
    /**
433
     * The array of 'to' addresses.
434
     * @type array
435
     * @access protected
436
     */
437
    protected $to = array();
404 438

  
405
  /**
406
   * Sets Mailer to send message using the $Sendmail program.
407
   * @return void
408
   */
409
  public function IsSendmail() {
410
    if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
411
      $this->Sendmail = '/var/qmail/bin/sendmail';
412
    }
413
    $this->Mailer = 'sendmail';
414
  }
439
    /**
440
     * The array of 'cc' addresses.
441
     * @type array
442
     * @access protected
443
     */
444
    protected $cc = array();
415 445

  
416
  /**
417
   * Sets Mailer to send message using the qmail MTA.
418
   * @return void
419
   */
420
  public function IsQmail() {
421
    if (stristr(ini_get('sendmail_path'), 'qmail')) {
422
      $this->Sendmail = '/var/qmail/bin/sendmail';
423
    }
424
    $this->Mailer = 'sendmail';
425
  }
446
    /**
447
     * The array of 'bcc' addresses.
448
     * @type array
449
     * @access protected
450
     */
451
    protected $bcc = array();
426 452

  
427
  /////////////////////////////////////////////////
428
  // METHODS, RECIPIENTS
429
  /////////////////////////////////////////////////
453
    /**
454
     * The array of reply-to names and addresses.
455
     * @type array
456
     * @access protected
457
     */
458
    protected $ReplyTo = array();
430 459

  
431
  /**
432
   * Adds a "To" address.
433
   * @param string $address
434
   * @param string $name
435
   * @return boolean true on success, false if address already used
436
   */
437
  public function AddAddress($address, $name = '') {
438
    return $this->AddAnAddress('to', $address, $name);
439
  }
460
    /**
461
     * An array of all kinds of addresses.
462
     * Includes all of $to, $cc, $bcc, $replyto
463
     * @type array
464
     * @access protected
465
     */
466
    protected $all_recipients = array();
440 467

  
441
  /**
442
   * Adds a "Cc" address.
443
   * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
444
   * @param string $address
445
   * @param string $name
446
   * @return boolean true on success, false if address already used
447
   */
448
  public function AddCC($address, $name = '') {
449
    return $this->AddAnAddress('cc', $address, $name);
450
  }
468
    /**
469
     * The array of attachments.
470
     * @type array
471
     * @access protected
472
     */
473
    protected $attachment = array();
451 474

  
452
  /**
453
   * Adds a "Bcc" address.
454
   * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
455
   * @param string $address
456
   * @param string $name
457
   * @return boolean true on success, false if address already used
458
   */
459
  public function AddBCC($address, $name = '') {
460
    return $this->AddAnAddress('bcc', $address, $name);
461
  }
475
    /**
476
     * The array of custom headers.
477
     * @type array
478
     * @access protected
479
     */
480
    protected $CustomHeader = array();
462 481

  
463
  /**
464
   * Adds a "Reply-to" address.
465
   * @param string $address
466
   * @param string $name
467
   * @return boolean
468
   */
469
  public function AddReplyTo($address, $name = '') {
470
    return $this->AddAnAddress('Reply-To', $address, $name);
471
  }
482
    /**
483
     * The most recent Message-ID (including angular brackets).
484
     * @type string
485
     * @access protected
486
     */
487
    protected $lastMessageID = '';
472 488

  
473
  /**
474
   * Adds an address to one of the recipient arrays
475
   * Addresses that have been added already return false, but do not throw exceptions
476
   * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
477
   * @param string $address The email address to send to
478
   * @param string $name
479
   * @return boolean true on success, false if address already used or invalid in some way
480
   * @access protected
481
   */
482
  protected function AddAnAddress($kind, $address, $name = '') {
483
    if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
484
      $this->SetError($this->Lang('Invalid recipient array').': '.$kind);
485
      if ($this->exceptions) {
486
        throw new phpmailerException('Invalid recipient array: ' . $kind);
487
      }
488
	  if ($this->SMTPDebug) {
489
        echo $this->Lang('Invalid recipient array').': '.$kind;
490
      }
491
      return false;
492
    }
493
    $address = trim($address);
494
    $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
495
    if (!self::ValidateAddress($address)) {
496
      $this->SetError($this->Lang('invalid_address').': '. $address);
497
      if ($this->exceptions) {
498
        throw new phpmailerException($this->Lang('invalid_address').': '.$address);
499
      }
500
	  if ($this->SMTPDebug) {
501
        echo $this->Lang('invalid_address').': '.$address;
502
      }
503
      return false;
504
    }
505
    if ($kind != 'Reply-To') {
506
      if (!isset($this->all_recipients[strtolower($address)])) {
507
        array_push($this->$kind, array($address, $name));
508
        $this->all_recipients[strtolower($address)] = true;
509
        return true;
510
      }
511
    } else {
512
      if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
513
        $this->ReplyTo[strtolower($address)] = array($address, $name);
514
      return true;
515
    }
516
  }
517
  return false;
518
}
489
    /**
490
     * The message's MIME type.
491
     * @type string
492
     * @access protected
493
     */
494
    protected $message_type = '';
519 495

  
520
/**
521
 * Set the From and FromName properties
522
 * @param string $address
523
 * @param string $name
524
 * @return boolean
525
 */
526
  public function SetFrom($address, $name = '', $auto = 1) {
527
    $address = trim($address);
528
    $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
529
    if (!self::ValidateAddress($address)) {
530
      $this->SetError($this->Lang('invalid_address').': '. $address);
531
      if ($this->exceptions) {
532
        throw new phpmailerException($this->Lang('invalid_address').': '.$address);
533
      }
534
	  if ($this->SMTPDebug) {
535
        echo $this->Lang('invalid_address').': '.$address;
536
      }
537
      return false;
538
    }
539
    $this->From = $address;
540
    $this->FromName = $name;
541
    if ($auto) {
542
      if (empty($this->ReplyTo)) {
543
        $this->AddAnAddress('Reply-To', $address, $name);
544
      }
545
      if (empty($this->Sender)) {
546
        $this->Sender = $address;
547
      }
548
    }
549
    return true;
550
  }
496
    /**
497
     * The array of MIME boundary strings.
498
     * @type array
499
     * @access protected
500
     */
501
    protected $boundary = array();
551 502

  
552
  /**
553
   * Check that a string looks roughly like an email address should
554
   * Static so it can be used without instantiation
555
   * Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator
556
   * Conforms approximately to RFC2822
557
   * @link http://www.hexillion.com/samples/#Regex Original pattern found here
558
   * @param string $address The email address to check
559
   * @return boolean
560
   * @static
561
   * @access public
562
   */
563
  public static function ValidateAddress($address) {
564
    if (function_exists('filter_var')) { //Introduced in PHP 5.2
565
      if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
566
        return false;
567
      } else {
568
        return true;
569
      }
570
    } else {
571
      return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
572
    }
573
  }
503
    /**
504
     * The array of available languages.
505
     * @type array
506
     * @access protected
507
     */
508
    protected $language = array();
574 509

  
575
  /////////////////////////////////////////////////
576
  // METHODS, MAIL SENDING
577
  /////////////////////////////////////////////////
510
    /**
511
     * The number of errors encountered.
512
     * @type integer
513
     * @access protected
514
     */
515
    protected $error_count = 0;
578 516

  
579
  /**
580
   * Creates message and assigns Mailer. If the message is
581
   * not sent successfully then it returns false.  Use the ErrorInfo
582
   * variable to view description of the error.
583
   * @return bool
584
   */
585
  public function Send() {
586
    try {
587
      if(!$this->PreSend()) return false;
588
      return $this->PostSend();
589
    } catch (phpmailerException $e) {
590
	  $this->SentMIMEMessage = '';
591
      $this->SetError($e->getMessage());
592
      if ($this->exceptions) {
593
        throw $e;
594
      }
595
      return false;
596
    }
597
  }
517
    /**
518
     * The S/MIME certificate file path.
519
     * @type string
520
     * @access protected
521
     */
522
    protected $sign_cert_file = '';
598 523

  
599
  protected function PreSend() {
600
    try {
601
	  $mailHeader = "";
602
      if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
603
        throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL);
604
      }
524
    /**
525
     * The S/MIME key file path.
526
     * @type string
527
     * @access protected
528
     */
529
    protected $sign_key_file = '';
605 530

  
606
      // Set whether the message is multipart/alternative
607
      if(!empty($this->AltBody)) {
608
        $this->ContentType = 'multipart/alternative';
609
      }
531
    /**
532
     * The S/MIME password for the key.
533
     * Used only if the key is encrypted.
534
     * @type string
535
     * @access protected
536
     */
537
    protected $sign_key_pass = '';
610 538

  
611
      $this->error_count = 0; // reset errors
612
      $this->SetMessageType();
613
      //Refuse to send an empty message
614
      if (empty($this->Body)) {
615
        throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL);
616
      }
539
    /**
540
     * Whether to throw exceptions for errors.
541
     * @type bool
542
     * @access protected
543
     */
544
    protected $exceptions = false;
617 545

  
618
      $this->MIMEHeader = $this->CreateHeader();
619
      $this->MIMEBody = $this->CreateBody();
546
    /**
547
     * Error severity: message only, continue processing
548
     */
549
    const STOP_MESSAGE = 0;
620 550

  
621
      // To capture the complete message when using mail(), create
622
	  // an extra header list which CreateHeader() doesn't fold in
623
      if ($this->Mailer == 'mail') {
624
        if (count($this->to) > 0) {
625
          $mailHeader .= $this->AddrAppend("To", $this->to);
626
        } else {
627
          $mailHeader .= $this->HeaderLine("To", "undisclosed-recipients:;");
628
        }
629
        $mailHeader .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader(trim($this->Subject))));
630
        // if(count($this->cc) > 0) {
631
            // $mailHeader .= $this->AddrAppend("Cc", $this->cc);
632
        // }
633
      }
551
    /**
552
     * Error severity: message, likely ok to continue processing
553
     */
554
    const STOP_CONTINUE = 1;
634 555

  
635
      // digitally sign with DKIM if enabled
636
      if ($this->DKIM_domain && $this->DKIM_private) {
637
        $header_dkim = $this->DKIM_Add($this->MIMEHeader, $this->EncodeHeader($this->SecureHeader($this->Subject)), $this->MIMEBody);
638
        $this->MIMEHeader = str_replace("\r\n", "\n", $header_dkim) . $this->MIMEHeader;
639
      }
556
    /**
557
     * Error severity: message, plus full stop, critical error reached
558
     */
559
    const STOP_CRITICAL = 2;
640 560

  
641
      $this->SentMIMEMessage = sprintf("%s%s\r\n\r\n%s",$this->MIMEHeader,$mailHeader,$this->MIMEBody);
642
      return true;
561
    /**
562
     * SMTP RFC standard line ending
563
     */
564
    const CRLF = "\r\n";
643 565

  
644
    } catch (phpmailerException $e) {
645
      $this->SetError($e->getMessage());
646
      if ($this->exceptions) {
647
        throw $e;
648
      }
649
      return false;
566
    /**
567
     * Constructor
568
     * @param bool $exceptions Should we throw external exceptions?
569
     */
570
    public function __construct($exceptions = false)
571
    {
572
        $this->exceptions = ($exceptions == true);
573
        //Make sure our autoloader is loaded
574
        if (!in_array('PHPMailerAutoload', spl_autoload_functions())) {
575
            require 'PHPMailerAutoload.php';
576
        }
650 577
    }
651
  }
652 578

  
653
  protected function PostSend() {
654
    try {
655
      // Choose the mailer and send through it
656
      switch($this->Mailer) {
657
        case 'sendmail':
658
          return $this->SendmailSend($this->MIMEHeader, $this->MIMEBody);
659
        case 'smtp':
660
          return $this->SmtpSend($this->MIMEHeader, $this->MIMEBody);
661
        case 'mail':
662
          return $this->MailSend($this->MIMEHeader, $this->MIMEBody);
663
        default:
664
          return $this->MailSend($this->MIMEHeader, $this->MIMEBody);
665
      }
579
    /**
580
     * Destructor.
581
     */
582
    public function __destruct()
583
    {
584
        if ($this->Mailer == 'smtp') { //close any open SMTP connection nicely
585
            $this->smtpClose();
586
        }
587
    }
666 588

  
667
    } catch (phpmailerException $e) {
668
      $this->SetError($e->getMessage());
669
      if ($this->exceptions) {
670
        throw $e;
671
      }
672
	  if ($this->SMTPDebug) {
673
        echo $e->getMessage()."\n";
674
      }
675
      return false;
589
    /**
590
     * Call mail() in a safe_mode-aware fashion.
591
     * Also, unless sendmail_path points to sendmail (or something that
592
     * claims to be sendmail), don't pass params (not a perfect fix,
593
     * but it will do)
594
     * @param string $to To
595
     * @param string $subject Subject
596
     * @param string $body Message Body
597
     * @param string $header Additional Header(s)
598
     * @param string $params Params
599
     * @access private
600
     * @return bool
601
     */
602
    private function mailPassthru($to, $subject, $body, $header, $params)
603
    {
604
        if (ini_get('safe_mode') || !($this->UseSendmailOptions)) {
605
            $rt = @mail($to, $this->encodeHeader($this->secureHeader($subject)), $body, $header);
606
        } else {
607
            $rt = @mail($to, $this->encodeHeader($this->secureHeader($subject)), $body, $header, $params);
608
        }
609
        return $rt;
676 610
    }
677
  }
678 611

  
679
  /**
680
   * Sends mail using the $Sendmail program.
681
   * @param string $header The message headers
682
   * @param string $body The message body
683
   * @access protected
684
   * @return bool
685
   */
686
  protected function SendmailSend($header, $body) {
687
    if ($this->Sender != '') {
688
      $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
689
    } else {
690
      $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
691
    }
692
    if ($this->SingleTo === true) {
693
      foreach ($this->SingleToArray as $key => $val) {
694
        if(!@$mail = popen($sendmail, 'w')) {
695
          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
612
    /**
613
     * Output debugging info via user-defined method.
614
     * Only if debug output is enabled.
615
     * @see PHPMailer::$Debugoutput
616
     * @see PHPMailer::$SMTPDebug
617
     * @param string $str
618
     */
619
    protected function edebug($str)
620
    {
621
        if (!$this->SMTPDebug) {
622
            return;
696 623
        }
697
        fputs($mail, "To: " . $val . "\n");
698
        fputs($mail, $header);
699
        fputs($mail, $body);
700
        $result = pclose($mail);
701
        // implement call back function if it exists
702
        $isSent = ($result == 0) ? 1 : 0;
703
        $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
704
        if($result != 0) {
705
          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
624
        switch ($this->Debugoutput) {
625
            case 'error_log':
626
                error_log($str);
627
                break;
628
            case 'html':
629
                //Cleans up output a bit for a better looking display that's HTML-safe
630
                echo htmlentities(preg_replace('/[\r\n]+/', '', $str), ENT_QUOTES, $this->CharSet) . "<br>\n";
631
                break;
632
            case 'echo':
633
            default:
634
                //Just echoes exactly what was received
635
                echo $str;
706 636
        }
707
      }
708
    } else {
709
      if(!@$mail = popen($sendmail, 'w')) {
710
        throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
711
      }
712
      fputs($mail, $header);
713
      fputs($mail, $body);
714
      $result = pclose($mail);
715
      // implement call back function if it exists
716
      $isSent = ($result == 0) ? 1 : 0;
717
      $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body);
718
      if($result != 0) {
719
        throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
720
      }
721 637
    }
722
    return true;
723
  }
724 638

  
725
  /**
726
   * Sends mail using the PHP mail() function.
727
   * @param string $header The message headers
728
   * @param string $body The message body
729
   * @access protected
730
   * @return bool
731
   */
732
  protected function MailSend($header, $body) {
733
    $toArr = array();
734
    foreach($this->to as $t) {
735
      $toArr[] = $this->AddrFormat($t);
639
    /**
640
     * Sets message type to HTML or plain.
641
     * @param bool $ishtml True for HTML mode.
642
     * @return void
643
     */
644
    public function isHTML($ishtml = true)
645
    {
646
        if ($ishtml) {
647
            $this->ContentType = 'text/html';
648
        } else {
649
            $this->ContentType = 'text/plain';
650
        }
736 651
    }
737
    $to = implode(', ', $toArr);
738 652

  
739
    if (empty($this->Sender)) {
740
      $params = "-oi ";
741
    } else {
742
      $params = sprintf("-oi -f %s", $this->Sender);
653
    /**
654
     * Send messages using SMTP.
655
     * @return void
656
     */
657
    public function isSMTP()
658
    {
659
        $this->Mailer = 'smtp';
743 660
    }
744
    if ($this->Sender != '' and !ini_get('safe_mode')) {
745
      $old_from = ini_get('sendmail_from');
746
      ini_set('sendmail_from', $this->Sender);
747
      if ($this->SingleTo === true && count($toArr) > 1) {
748
        foreach ($toArr as $key => $val) {
749
          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
750
          // implement call back function if it exists
751
          $isSent = ($rt == 1) ? 1 : 0;
752
          $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
661

  
662
    /**
663
     * Send messages using PHP's mail() function.
664
     * @return void
665
     */
666
    public function isMail()
667
    {
668
        $this->Mailer = 'mail';
669
    }
670

  
671
    /**
672
     * Send messages using $Sendmail.
673
     * @return void
674
     */
675
    public function isSendmail()
676
    {
677
        if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
678
            $this->Sendmail = '/var/qmail/bin/sendmail';
753 679
        }
754
      } else {
755
        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
756
        // implement call back function if it exists
757
        $isSent = ($rt == 1) ? 1 : 0;
758
        $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
759
      }
760
    } else {
761
      if ($this->SingleTo === true && count($toArr) > 1) {
762
        foreach ($toArr as $key => $val) {
763
          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
764
          // implement call back function if it exists
765
          $isSent = ($rt == 1) ? 1 : 0;
766
          $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
680
        $this->Mailer = 'sendmail';
681
    }
682

  
683
    /**
684
     * Send messages using qmail.
685
     * @return void
686
     */
687
    public function isQmail()
688
    {
689
        if (stristr(ini_get('sendmail_path'), 'qmail')) {
690
            $this->Sendmail = '/var/qmail/bin/sendmail';
767 691
        }
768
      } else {
769
        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
770
        // implement call back function if it exists
771
        $isSent = ($rt == 1) ? 1 : 0;
772
        $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
773
      }
692
        $this->Mailer = 'sendmail';
774 693
    }
775
    if (isset($old_from)) {
776
      ini_set('sendmail_from', $old_from);
777
    }
778
    if(!$rt) {
779
      throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
780
    }
781
    return true;
782
  }
783 694

  
784
  /**
785
   * Sends mail via SMTP using PhpSMTP
786
   * Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
787
   * @param string $header The message headers
788
   * @param string $body The message body
789
   * @uses SMTP
790
   * @access protected
791
   * @return bool
792
   */
793
  protected function SmtpSend($header, $body) {
794
    require_once $this->PluginDir . 'class.smtp.php';
795
    $bad_rcpt = array();
796

  
797
    if(!$this->SmtpConnect()) {
798
      throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
695
    /**
696
     * Add a "To" address.
697
     * @param string $address
698
     * @param string $name
699
     * @return bool true on success, false if address already used
700
     */
701
    public function addAddress($address, $name = '')
702
    {
703
        return $this->addAnAddress('to', $address, $name);
799 704
    }
800
    $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
801
    if(!$this->smtp->Mail($smtp_from)) {
802
      throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
803
    }
804 705

  
805
    // Attempt to send attach all recipients
806
    foreach($this->to as $to) {
807
      if (!$this->smtp->Recipient($to[0])) {
808
        $bad_rcpt[] = $to[0];
809
        // implement call back function if it exists
810
        $isSent = 0;
811
        $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
812
      } else {
813
        // implement call back function if it exists
814
        $isSent = 1;
815
        $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
816
      }
706
    /**
707
     * Add a "CC" address.
708
     * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
709
     * @param string $address
710
     * @param string $name
711
     * @return bool true on success, false if address already used
712
     */
713
    public function addCC($address, $name = '')
714
    {
715
        return $this->addAnAddress('cc', $address, $name);
817 716
    }
818
    foreach($this->cc as $cc) {
819
      if (!$this->smtp->Recipient($cc[0])) {
820
        $bad_rcpt[] = $cc[0];
821
        // implement call back function if it exists
822
        $isSent = 0;
823
        $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
824
      } else {
825
        // implement call back function if it exists
826
        $isSent = 1;
827
        $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
828
      }
829
    }
830
    foreach($this->bcc as $bcc) {
831
      if (!$this->smtp->Recipient($bcc[0])) {
832
        $bad_rcpt[] = $bcc[0];
833
        // implement call back function if it exists
834
        $isSent = 0;
835
        $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
836
      } else {
837
        // implement call back function if it exists
838
        $isSent = 1;
839
        $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
840
      }
841
    }
842 717

  
843

  
844
    if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
845
      $badaddresses = implode(', ', $bad_rcpt);
846
      throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
718
    /**
719
     * Add a "BCC" address.
720
     * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
721
     * @param string $address
722
     * @param string $name
723
     * @return bool true on success, false if address already used
724
     */
725
    public function addBCC($address, $name = '')
726
    {
727
        return $this->addAnAddress('bcc', $address, $name);
847 728
    }
848
    if(!$this->smtp->Data($header . $body)) {
849
      throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
850
    }
851
    if($this->SMTPKeepAlive == true) {
852
      $this->smtp->Reset();
853
    }
854
    return true;
855
  }
856 729

  
857
  /**
858
   * Initiates a connection to an SMTP server.
859
   * Returns false if the operation failed.
860
   * @uses SMTP
861
   * @access public
862
   * @return bool
863
   */
864
  public function SmtpConnect() {
865
    if(is_null($this->smtp)) {
866
      $this->smtp = new SMTP();
730
    /**
731
     * Add a "Reply-to" address.
732
     * @param string $address
733
     * @param string $name
734
     * @return bool
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff