MailPoet Newsletters (Previous) - Version 2.7.8

Version Description

  • 2017-03-03 =
  • Fixed sending issues when MailPoet's sending service is selected
  • Fixed sending post notifications when tag filters are used
  • Fixed the display of incorrect newsletter title in browser preview
  • Fixed PHP notices associated with sending on multisite hosts
  • Fixed broken DKIM signing
Download this release

Release Info

Developer wysija
Plugin Icon 128x128 MailPoet Newsletters (Previous)
Version 2.7.8
Comparing to
See all releases

Code changes from version 2.7.6 to 2.7.8

classes/WJ_Bridge.php CHANGED
@@ -10,6 +10,7 @@ class WJ_Bridge {
10
 
11
  public function send_mail(& $object)
12
  {
 
13
 
14
  $msg = array(
15
  'to' => array(
@@ -17,7 +18,8 @@ class WJ_Bridge {
17
  'address' => $object->to[0][0] ),
18
  'reply_to'=> array(
19
  'name' => '' ,
20
- 'address' => $object->ReplyTo[0][0] ),
 
21
  'from' => array(
22
  'name' => $object->FromName ,
23
  'address' => $object->From ),
10
 
11
  public function send_mail(& $object)
12
  {
13
+ $replyToKey = key($object->ReplyTo);
14
 
15
  $msg = array(
16
  'to' => array(
18
  'address' => $object->to[0][0] ),
19
  'reply_to'=> array(
20
  'name' => '' ,
21
+ 'address' => $object->ReplyTo[$replyToKey][0]
22
+ ),
23
  'from' => array(
24
  'name' => $object->FromName ,
25
  'address' => $object->From ),
controllers/back/campaigns.php CHANGED
@@ -650,6 +650,7 @@ class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
650
  function editDetails() {
651
  if (!$this->_checkEmailExists($_REQUEST['id']))
652
  return;
 
653
  $this->viewObj->title = __('Final step: last details', WYSIJA);
654
  $this->viewShow = 'editDetails';
655
  $this->js[] = 'wysija-validator';
@@ -681,7 +682,6 @@ class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
681
  $this->data['email']['replyto_name'] = $current_user->data->display_name;
682
  }
683
 
684
-
685
  if ((int) $this->data['email']['type'] == 2) {
686
  $this->js['wysija-edit-autonl'] = 'wysija-edit-autonl';
687
  $this->jsTrans['autonl'] = true;
@@ -785,7 +785,6 @@ class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
785
  $this->requireSecurity();
786
  /* update email */
787
  $data = array();
788
-
789
  // in case the newsletter already exists
790
  if (isset($_REQUEST['id'])) {
791
  $modelEmail = WYSIJA::get('email', 'model');
@@ -1286,7 +1285,14 @@ class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
1286
  $model_email->reset();
1287
  $model_email->columns['modified_at']['autoup'] = 1;
1288
 
1289
- // update some fields of the email
 
 
 
 
 
 
 
1290
  $model_email->update($update_email);
1291
 
1292
  // update the campaign subject which ispretty much useless but good to keep in sync with the email
650
  function editDetails() {
651
  if (!$this->_checkEmailExists($_REQUEST['id']))
652
  return;
653
+
654
  $this->viewObj->title = __('Final step: last details', WYSIJA);
655
  $this->viewShow = 'editDetails';
656
  $this->js[] = 'wysija-validator';
682
  $this->data['email']['replyto_name'] = $current_user->data->display_name;
683
  }
684
 
 
685
  if ((int) $this->data['email']['type'] == 2) {
686
  $this->js['wysija-edit-autonl'] = 'wysija-edit-autonl';
687
  $this->jsTrans['autonl'] = true;
785
  $this->requireSecurity();
786
  /* update email */
787
  $data = array();
 
788
  // in case the newsletter already exists
789
  if (isset($_REQUEST['id'])) {
790
  $modelEmail = WYSIJA::get('email', 'model');
1285
  $model_email->reset();
1286
  $model_email->columns['modified_at']['autoup'] = 1;
1287
 
1288
+ // re-render and save newsletter body (title may change during the last newsletter creation step)
1289
+ $wj_engine = WYSIJA::get('wj_engine', 'helper');
1290
+ // set data & styles
1291
+ $wj_engine->setData($email_data['wj_data'], true);
1292
+ $wj_engine->setStyles($email_data['wj_styles'], true);
1293
+ $email_data['subject'] = $_POST['wysija']['email']['subject'];
1294
+ $update_email['body'] = $wj_engine->renderEmail($email_data);
1295
+ // update some fields of the email
1296
  $model_email->update($update_email);
1297
 
1298
  // update the campaign subject which ispretty much useless but good to keep in sync with the email
core/base.php CHANGED
@@ -19,7 +19,7 @@ class WYSIJA_object{
19
  * Static variable holding core MailPoet's version
20
  * @var array
21
  */
22
- static $version = '2.7.6';
23
 
24
  function __construct(){}
25
 
@@ -1616,8 +1616,8 @@ add_action( 'init', array('WYSIJA','create_post_type') );
1616
  // check for PHP version and display a warning notice if it's <5.3
1617
  if ( version_compare( PHP_VERSION , '5.3' , '<' ) &&
1618
  !get_option("wysija_dismiss_update_notice") &&
1619
- empty($_SERVER['HTTP_X_REQUESTED_WITH']) &&
1620
- strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
1621
 
1622
  $a = new WYSIJA_object();
1623
  $a->notice(__("Your version of PHP is outdated. If you don't upgrade soon, new versions of MailPoet won't work.")
19
  * Static variable holding core MailPoet's version
20
  * @var array
21
  */
22
+ static $version = '2.7.8';
23
 
24
  function __construct(){}
25
 
1616
  // check for PHP version and display a warning notice if it's <5.3
1617
  if ( version_compare( PHP_VERSION , '5.3' , '<' ) &&
1618
  !get_option("wysija_dismiss_update_notice") &&
1619
+ empty($_SERVER['HTTP_X_REQUESTED_WITH'])
1620
+ ) {
1621
 
1622
  $a = new WYSIJA_object();
1623
  $a->notice(__("Your version of PHP is outdated. If you don't upgrade soon, new versions of MailPoet won't work.")
helpers/email.php CHANGED
@@ -45,16 +45,15 @@ class WYSIJA_help_email extends WYSIJA_object{
45
  'smtp_auth'=>'smtp_auth',
46
  );
47
 
48
- //add a prefix to each option if we are in ms test case
49
  if($testMultisite){
50
  $is_multisite=is_multisite();
51
 
52
  //$is_multisite=true;//PROD comment that line
53
  if(!$is_multisite) return false;
54
- foreach($options as &$option) $option='ms_'.$option;
55
  }
56
 
57
  switch($values[$options['sending_method']]){
 
58
  case 'site':
59
  if($values[$options['sending_emails_site_method']]=='phpmail'){
60
  $send_method='PHP Mail';
45
  'smtp_auth'=>'smtp_auth',
46
  );
47
 
 
48
  if($testMultisite){
49
  $is_multisite=is_multisite();
50
 
51
  //$is_multisite=true;//PROD comment that line
52
  if(!$is_multisite) return false;
 
53
  }
54
 
55
  switch($values[$options['sending_method']]){
56
+ case 'network':
57
  case 'site':
58
  if($values[$options['sending_emails_site_method']]=='phpmail'){
59
  $send_method='PHP Mail';
helpers/mailer.php CHANGED
@@ -5,8 +5,8 @@
5
  */
6
  defined( 'WYSIJA' ) || die( 'Restricted access' );
7
 
8
- require_once WYSIJA_DIR . 'inc' . DS . 'phpmailer' . DS . 'class.phpmailer.php';
9
- class WYSIJA_help_mailer extends acymailingPHPMailer {
10
  var $report = true;
11
  var $checkConfirmField = true;
12
  var $checkEnabled = true;
@@ -33,6 +33,16 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
33
  var $listnames = false;
34
  var $is_wp_mail = false;
35
 
 
 
 
 
 
 
 
 
 
 
36
  /**
37
  *
38
  * @param type $extension
@@ -40,7 +50,9 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
40
  * @param boolean $multisiteTest
41
  */
42
  function __construct($extension='',$config=false, $multisiteTest=false) {
 
43
 
 
44
  $this->subscriberClass = WYSIJA::get( 'user', 'model' );
45
  $this->subscriberClass->getFormat = OBJECT;
46
 
@@ -95,7 +107,7 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
95
 
96
  if(in_array(trim($this->Host), array('smtp.elasticemail.com','smtp25.elasticemail.com'))){
97
  //REST API!
98
- include_once (WYSIJA_INC. 'phpmailer' . DS . 'class.elasticemail.php');
99
  $this->Mailer = 'elasticemail';
100
  $this->elasticEmail = new acymailingElasticemail();
101
  $this->elasticEmail->Username = trim($this->config->getValue('smtp_login'));
@@ -103,7 +115,7 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
103
  $this->isElasticRest=true;
104
  }elseif(in_array(trim($this->Host), array('smtp.sendgrid.net')) && $this->config->getValue('smtp_rest')){
105
  //REST API!
106
- include_once (WYSIJA_INC. 'phpmailer' . DS . 'class.sendgrid.php');
107
  $this->Mailer = 'sendgrid';
108
  $this->sendGrid = new acymailingSendgrid();
109
  $this->sendGrid->Username = trim($this->config->getValue('smtp_login'));
@@ -172,16 +184,32 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
172
  if($this->config->getValue('dkim_active') && $this->config->getValue('dkim_pubk') && !$this->isElasticRest && !$this->isSendGridRest && $this->Mailer !== 'mailpoet' && $this->Mailer !== 'sparkpost'){
173
  // check that server can sign emails
174
  if(!function_exists('openssl_sign')){
175
- $this->error(__('You cannot use the DKIM signature option...',WYSIJA).' '.__('The PHP Extension openssl is not enabled on your server. Ask your host to enable it if you want to use an SSL connection.',WYSIJA));
176
  }else{
177
  $this->DKIM_domain = $this->config->getValue('dkim_domain');
178
- $this->DKIM_private = trim($this->config->getValue('dkim_privk'));
 
179
  }
180
  }
181
 
182
  $this->DKIM_selector = 'wys';
 
 
 
 
 
 
 
183
  }
184
 
 
 
 
 
 
 
 
 
185
  function IsWPmail() {
186
  $this->is_wp_mail = true;
187
  $this->Mailer = 'wpmail';
@@ -257,14 +285,14 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
257
  $this->reportMessage.=' | '.$error['error'];
258
  }
259
  $this->ErrorInfo=array();
260
- //$this->error($this->ErrorInfo);
261
  //$this->reportMessage();
262
  }
263
 
264
  if(!empty($warnings)) $this->reportMessage .= ' | '.$warnings;
265
  $this->errorNumber = 1;
266
  if($this->report){
267
- $this->error($this->reportMessage);
268
  }
269
 
270
  }else{
@@ -273,7 +301,7 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
273
  if($this->report){
274
  if(!empty($warnings)){
275
  $this->reportMessage .= ' | '.$warnings;
276
- $this->notice($this->reportMessage,false);
277
  }
278
  }
279
  }
@@ -327,24 +355,24 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
327
  return $this->defaultMail[ $email_id ];
328
  }
329
 
330
- function wpmail_init( $phpmailer ){
331
- $phpmailer->ClearCustomHeaders();
332
- $phpmailer->Body = $this->AltBody;
333
- $phpmailer->AltBody = $this->AltBody;
334
- $phpmailer->Subject = $this->Subject;
335
- $phpmailer->From = $this->From;
336
- $phpmailer->FromName = $this->FromName;
337
- $phpmailer->Sender = $this->Sender;
338
- $phpmailer->MessageID = $this->MessageID;
339
 
340
- $phpmailer->AddAddress( $this->to[0][0], $this->to[0][1] );
341
- $phpmailer->AddReplyTo( $this->ReplyTo[0][0], $this->ReplyTo[0][1] );
342
 
343
- $phpmailer->CharSet = $this->CharSet;
344
- $phpmailer->Encoding = $this->Encoding;
345
- $phpmailer->WordWrap = $this->WordWrap;
346
 
347
- return $phpmailer;
348
  }
349
 
350
  function recordEmail( $email_id, $email_object = false ){
@@ -481,7 +509,7 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
481
  if(!$this->load($email_id)){
482
  $this->reportMessage = 'Can not load the email : '.$email_id;
483
  if($this->report){
484
- $this->error($this->reportMessage);
485
  }
486
  $this->errorNumber = 2;
487
  return false;
@@ -505,7 +533,7 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
505
  $this->reportMessage = sprintf(__('The email ID %s is not published',WYSIJA),$email_id);
506
  $this->errorNumber = 3;
507
  if($this->report){
508
- $this->error($this->reportMessage);
509
  }
510
  return false;
511
  }
@@ -548,7 +576,7 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
548
  if(empty($receiver->email)){
549
  $this->reportMessage = sprintf(__('Subscriber not found : <b><i>%s</i></b>',WYSIJA),isset($receiver->user_id) ? (int)$receiver->user_id : (int)$receiverid);
550
  if($this->report){
551
- $this->error($this->reportMessage);
552
  }
553
  $this->errorNumber = 4;
554
  return false;
@@ -573,7 +601,7 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
573
  if(/*!isset($this->defaultMail[$email_id]->simple) &&*/ $this->checkConfirmField AND empty($receiver->status) AND $this->config->getValue('confirm_dbleoptin')==1 AND $email_id != $this->config->getValue('confirm_email_id')){
574
  $this->reportMessage = sprintf(__($this->config->getValue('confirm_dbleoptin').' The subscriber <b><i>%s</i></b> is not confirmed',WYSIJA),esc_html($receiver->email));
575
  if($this->report){
576
- $this->error($this->reportMessage);
577
  }
578
  $this->errorNumber = 5;
579
  return false;
@@ -731,7 +759,7 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
731
  function cleanText($text){
732
  return trim( preg_replace( '/(%0A|%0D|\n+|\r+)/i', '', (string) $text ) );
733
  }
734
- function setFrom($email,$name=''){
735
  if(!empty($email)){
736
  $this->From = $this->cleanText($email);
737
  }
@@ -1121,4 +1149,48 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
1121
  $this->sendHTML = $ishtml;
1122
  }
1123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1124
  }
5
  */
6
  defined( 'WYSIJA' ) || die( 'Restricted access' );
7
 
8
+ require_once ABSPATH . WPINC . '/class-phpmailer.php';
9
+ class WYSIJA_help_mailer extends PHPMailer {
10
  var $report = true;
11
  var $checkConfirmField = true;
12
  var $checkEnabled = true;
33
  var $listnames = false;
34
  var $is_wp_mail = false;
35
 
36
+ /**
37
+ * Change parent properties scope for legacy compatibility
38
+ */
39
+ public $to = array();
40
+ public $cc = array();
41
+ public $bcc = array();
42
+ public $ReplyTo = array();
43
+ public $all_recipients = array();
44
+ public $attachment = array();
45
+
46
  /**
47
  *
48
  * @param type $extension
50
  * @param boolean $multisiteTest
51
  */
52
  function __construct($extension='',$config=false, $multisiteTest=false) {
53
+ $this->core = new WYSIJA_OBJECT();
54
 
55
+ $this->XMailer = 'MailPoet (https://www.mailpoet.com)';
56
  $this->subscriberClass = WYSIJA::get( 'user', 'model' );
57
  $this->subscriberClass->getFormat = OBJECT;
58
 
107
 
108
  if(in_array(trim($this->Host), array('smtp.elasticemail.com','smtp25.elasticemail.com'))){
109
  //REST API!
110
+ include_once (WYSIJA_INC. 'mailer' . DS . 'class.elasticemail.php');
111
  $this->Mailer = 'elasticemail';
112
  $this->elasticEmail = new acymailingElasticemail();
113
  $this->elasticEmail->Username = trim($this->config->getValue('smtp_login'));
115
  $this->isElasticRest=true;
116
  }elseif(in_array(trim($this->Host), array('smtp.sendgrid.net')) && $this->config->getValue('smtp_rest')){
117
  //REST API!
118
+ include_once (WYSIJA_INC. 'mailer' . DS . 'class.sendgrid.php');
119
  $this->Mailer = 'sendgrid';
120
  $this->sendGrid = new acymailingSendgrid();
121
  $this->sendGrid->Username = trim($this->config->getValue('smtp_login'));
184
  if($this->config->getValue('dkim_active') && $this->config->getValue('dkim_pubk') && !$this->isElasticRest && !$this->isSendGridRest && $this->Mailer !== 'mailpoet' && $this->Mailer !== 'sparkpost'){
185
  // check that server can sign emails
186
  if(!function_exists('openssl_sign')){
187
+ $this->core->error(__('You cannot use the DKIM signature option...',WYSIJA).' '.__('The PHP Extension openssl is not enabled on your server. Ask your host to enable it if you want to use an SSL connection.',WYSIJA));
188
  }else{
189
  $this->DKIM_domain = $this->config->getValue('dkim_domain');
190
+ $this->DKIM_private = tempnam(sys_get_temp_dir(), 'pk');
191
+ file_put_contents($this->DKIM_private, trim($this->config->getValue('dkim_privk')));
192
  }
193
  }
194
 
195
  $this->DKIM_selector = 'wys';
196
+
197
+ /**
198
+ * SMTP class overriding for Mailer versions < 5.2.7
199
+ */
200
+ if ($this->Mailer == 'smtp' && !is_callable('parent::getSMTPInstance')) {
201
+ $this->getSMTPInstance();
202
+ }
203
  }
204
 
205
+ function __destruct() {
206
+ if($this->config->getValue('dkim_active')
207
+ && file_exists($this->DKIM_private)
208
+ ) {
209
+ @unlink($this->DKIM_private);
210
+ }
211
+ }
212
+
213
  function IsWPmail() {
214
  $this->is_wp_mail = true;
215
  $this->Mailer = 'wpmail';
285
  $this->reportMessage.=' | '.$error['error'];
286
  }
287
  $this->ErrorInfo=array();
288
+ //$this->core->error($this->ErrorInfo);
289
  //$this->reportMessage();
290
  }
291
 
292
  if(!empty($warnings)) $this->reportMessage .= ' | '.$warnings;
293
  $this->errorNumber = 1;
294
  if($this->report){
295
+ $this->core->error($this->reportMessage);
296
  }
297
 
298
  }else{
301
  if($this->report){
302
  if(!empty($warnings)){
303
  $this->reportMessage .= ' | '.$warnings;
304
+ $this->core->notice($this->reportMessage,false);
305
  }
306
  }
307
  }
355
  return $this->defaultMail[ $email_id ];
356
  }
357
 
358
+ function wpmail_init( $mailer ){
359
+ $mailer->ClearCustomHeaders();
360
+ $mailer->Body = $this->AltBody;
361
+ $mailer->AltBody = $this->AltBody;
362
+ $mailer->Subject = $this->Subject;
363
+ $mailer->From = $this->From;
364
+ $mailer->FromName = $this->FromName;
365
+ $mailer->Sender = $this->Sender;
366
+ $mailer->MessageID = $this->MessageID;
367
 
368
+ $mailer->AddAddress( $this->to[0][0], $this->to[0][1] );
369
+ $mailer->AddReplyTo( $this->ReplyTo[0][0], $this->ReplyTo[0][1] );
370
 
371
+ $mailer->CharSet = $this->CharSet;
372
+ $mailer->Encoding = $this->Encoding;
373
+ $mailer->WordWrap = $this->WordWrap;
374
 
375
+ return $mailer;
376
  }
377
 
378
  function recordEmail( $email_id, $email_object = false ){
509
  if(!$this->load($email_id)){
510
  $this->reportMessage = 'Can not load the email : '.$email_id;
511
  if($this->report){
512
+ $this->core->error($this->reportMessage);
513
  }
514
  $this->errorNumber = 2;
515
  return false;
533
  $this->reportMessage = sprintf(__('The email ID %s is not published',WYSIJA),$email_id);
534
  $this->errorNumber = 3;
535
  if($this->report){
536
+ $this->core->error($this->reportMessage);
537
  }
538
  return false;
539
  }
576
  if(empty($receiver->email)){
577
  $this->reportMessage = sprintf(__('Subscriber not found : <b><i>%s</i></b>',WYSIJA),isset($receiver->user_id) ? (int)$receiver->user_id : (int)$receiverid);
578
  if($this->report){
579
+ $this->core->error($this->reportMessage);
580
  }
581
  $this->errorNumber = 4;
582
  return false;
601
  if(/*!isset($this->defaultMail[$email_id]->simple) &&*/ $this->checkConfirmField AND empty($receiver->status) AND $this->config->getValue('confirm_dbleoptin')==1 AND $email_id != $this->config->getValue('confirm_email_id')){
602
  $this->reportMessage = sprintf(__($this->config->getValue('confirm_dbleoptin').' The subscriber <b><i>%s</i></b> is not confirmed',WYSIJA),esc_html($receiver->email));
603
  if($this->report){
604
+ $this->core->error($this->reportMessage);
605
  }
606
  $this->errorNumber = 5;
607
  return false;
759
  function cleanText($text){
760
  return trim( preg_replace( '/(%0A|%0D|\n+|\r+)/i', '', (string) $text ) );
761
  }
762
+ function setFrom($email,$name='',$auto=true){
763
  if(!empty($email)){
764
  $this->From = $this->cleanText($email);
765
  }
1149
  $this->sendHTML = $ishtml;
1150
  }
1151
 
1152
+ /**
1153
+ * Overrides parent method
1154
+ */
1155
+ public function getSMTPInstance() {
1156
+ if (!is_object($this->smtp)) {
1157
+ require_once WYSIJA_DIR . 'inc' . DS . 'mailer' . DS . 'class.mysmtp.php';
1158
+ $this->smtp = new WYSIJA_MySMTP;
1159
+ }
1160
+ return $this->smtp;
1161
+ }
1162
+
1163
+ /**
1164
+ * Overrides parent method
1165
+ */
1166
+ public function postSend() {
1167
+ switch($this->Mailer) {
1168
+ case 'elasticemail' :
1169
+ $result = $this->elasticEmail->sendMail($this);
1170
+ if (!$result) $this->SetError($this->elasticEmail->error);
1171
+ break;
1172
+ case 'sendgrid' :
1173
+ $result = $this->sendGrid->sendMail($this);
1174
+ if (!$result) $this->SetError($this->sendGrid->error);
1175
+ break;
1176
+ case 'sparkpost' :
1177
+ $result = $this->sparkpost->send_mail($this);
1178
+ if ( $result !== true ) $this->core->error($this->sparkpost->error);
1179
+ break;
1180
+ case 'mailpoet' :
1181
+ $result = $this->mailpoet->send_mail($this);
1182
+ if ( $result !== true ) $this->core->error($this->mailpoet->error);
1183
+ break;
1184
+ case 'wpmail' :
1185
+ $to = array_filter($this->to[0]);
1186
+ add_filter('phpmailer_init',array($this,'wpmail_init'),90);
1187
+ $result = wp_mail($to[0], $this->Subject, $this->Body, $header);
1188
+ break;
1189
+ default:
1190
+ $result = parent::postSend();
1191
+ break;
1192
+ }
1193
+
1194
+ return $result;
1195
+ }
1196
  }
helpers/wp_tools.php CHANGED
@@ -310,16 +310,21 @@ class WYSIJA_help_wp_tools extends WYSIJA_object{
310
  }
311
 
312
  function get_post_category_ids( $post = null ) {
313
- if ( ! is_object( $post ) || ! is_a( $post, 'WP_Post' ) ) {
314
- return array();
315
- }
316
- return array_map(function($category) { return $category->cat_ID; }, get_the_category($post->ID));
317
  }
318
 
319
  function get_post_categories( $post = null ) {
320
- if ( ! is_array( $post ) || empty($post['ID'] )) {
321
- return array();
322
- }
323
- return array_map(function($category) { return $category->name; }, get_the_category($post['ID']));
 
 
 
 
 
324
  }
325
  }
310
  }
311
 
312
  function get_post_category_ids( $post = null ) {
313
+ if ( ! is_object( $post ) || ! is_a( $post, 'WP_Post' ) ) {
314
+ return array();
315
+ }
316
+ return wp_get_post_terms( $post->ID, get_object_taxonomies( $post->post_type ), array( 'fields' => 'ids' ));
317
  }
318
 
319
  function get_post_categories( $post = null ) {
320
+ if ( ! is_array( $post ) || empty($post['ID'] )) {
321
+ return array();
322
+ }
323
+ $post_categories = get_the_category($post['ID']);
324
+ $post_categories_names = array();
325
+ foreach ($post_categories as $post_category) {
326
+ $post_categories_names[] = $post_category->name;
327
+ }
328
+ return $post_categories_names;
329
  }
330
  }
inc/{phpmailer → mailer}/LICENSE RENAMED
File without changes
inc/{phpmailer → mailer}/class.elasticemail.php RENAMED
@@ -68,8 +68,11 @@ class acymailingElasticemail {
68
  if (!empty ($object->Subject)) $data .= "&subject=" . urlencode($object->Subject);
69
 
70
  if (!empty($object->ReplyTo)){
71
- $data .="&reply_to=". urlencode($object->ReplyTo[0][0]);
72
- if(!empty($object->ReplyTo[0][1])) $data .="&reply_to_name=". urlencode($object->ReplyTo[0][1]);
 
 
 
73
  }
74
 
75
  if (!empty($object->Sender)) $data .="&sender=".urlencode($object->Sender);
68
  if (!empty ($object->Subject)) $data .= "&subject=" . urlencode($object->Subject);
69
 
70
  if (!empty($object->ReplyTo)){
71
+ $replyToKey = key($object->ReplyTo);
72
+ $data .="&reply_to=". urlencode($object->ReplyTo[$replyToKey][0]);
73
+ if(!empty($object->ReplyTo[$replyToKey][1])) {
74
+ $data .="&reply_to_name=". urlencode($object->ReplyTo[$replyToKey][1]);
75
+ }
76
  }
77
 
78
  if (!empty($object->Sender)) $data .="&sender=".urlencode($object->Sender);
inc/mailer/class.mysmtp.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
+
4
+ require_once ABSPATH . WPINC . '/class-smtp.php';
5
+ class WYSIJA_MySMTP extends SMTP {
6
+ public function StartTLS() {
7
+ stream_context_set_option($this->smtp_conn, "ssl", "verify_peer", false);
8
+ stream_context_set_option($this->smtp_conn, "ssl", "verify_peer_name", false);
9
+ stream_context_set_option($this->smtp_conn, "ssl", "allow_self_signed", true);
10
+ return parent::StartTLS();
11
+ }
12
+ }
inc/{phpmailer → mailer}/class.sendgrid.php RENAMED
@@ -27,16 +27,20 @@ class acymailingSendgrid {
27
  /*foreach($to as $oneRecipient){
28
  $data .= '&to[]='.urlencode($object->AddrFormat($oneRecipient).";");
29
  }*/
 
 
30
  $params = array(
31
  'api_user' => $this->Username,
32
  'api_key' => $this->Password,
33
  'to' => array_filter($to),
34
- 'replyto'=> $object->ReplyTo[0][0],
35
  'from' => $object->From,
36
  'fromname' => $object->FromName,
37
  );
38
 
39
- if(!empty($object->ReplyTo[0][1])) $params['replytoname']= $object->ReplyTo[0][1];
 
 
40
 
41
  if (!empty ($object->Subject)) $params['subject']= $object->Subject;
42
 
@@ -66,6 +70,8 @@ class acymailingSendgrid {
66
  $params['headers']=json_encode($header);
67
  $request = $url.'/api/mail.send.json';
68
 
 
 
69
  // Generate curl request
70
  $session = curl_init($request);
71
 
@@ -79,21 +85,31 @@ class acymailingSendgrid {
79
  curl_setopt($session, CURLOPT_HEADER, false);
80
  curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
81
 
 
 
 
 
82
  // obtain response
83
  $result = curl_exec($session);
 
 
 
 
 
84
  curl_close($session);
85
 
86
  //We take the last value of the server's response which correspond of the file's ID.
87
  $result=json_decode($result);
88
 
89
  //If the ID is correct and we have no Errors
90
- $this->error='';
91
- if(isset($result->message) && $result->message=='error'){
92
- foreach($result->errors as $msgError)
93
- $this->error .= $msgError."\n\r";
94
- return false;
95
  } else {
96
- return true;
 
 
 
 
97
  }
98
  }
99
 
27
  /*foreach($to as $oneRecipient){
28
  $data .= '&to[]='.urlencode($object->AddrFormat($oneRecipient).";");
29
  }*/
30
+ $replyToKey = key($object->ReplyTo);
31
+
32
  $params = array(
33
  'api_user' => $this->Username,
34
  'api_key' => $this->Password,
35
  'to' => array_filter($to),
36
+ 'replyto'=> $object->ReplyTo[$replyToKey][0],
37
  'from' => $object->From,
38
  'fromname' => $object->FromName,
39
  );
40
 
41
+ if(!empty($object->ReplyTo[$replyToKey][1])) {
42
+ $params['replytoname']= $object->ReplyTo[$replyToKey][1];
43
+ }
44
 
45
  if (!empty ($object->Subject)) $params['subject']= $object->Subject;
46
 
70
  $params['headers']=json_encode($header);
71
  $request = $url.'/api/mail.send.json';
72
 
73
+ $this->error='';
74
+
75
  // Generate curl request
76
  $session = curl_init($request);
77
 
85
  curl_setopt($session, CURLOPT_HEADER, false);
86
  curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
87
 
88
+ // Disable verification for misconfigured hosts :(
89
+ curl_setopt($session, CURLOPT_SSL_VERIFYHOST, false);
90
+ curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
91
+
92
  // obtain response
93
  $result = curl_exec($session);
94
+
95
+ if (!$result) {
96
+ $this->error .= curl_error($session);
97
+ }
98
+
99
  curl_close($session);
100
 
101
  //We take the last value of the server's response which correspond of the file's ID.
102
  $result=json_decode($result);
103
 
104
  //If the ID is correct and we have no Errors
105
+ if(isset($result->message) && $result->message=='success'){
106
+ return true;
 
 
 
107
  } else {
108
+ if(isset($result->message) && $result->message=='error'){
109
+ foreach($result->errors as $msgError)
110
+ $this->error .= $msgError."\n\r";
111
+ }
112
+ return false;
113
  }
114
  }
115
 
inc/{phpmailer → mailer}/index.html RENAMED
File without changes
inc/phpmailer/class.phpmailer.php DELETED
@@ -1,2159 +0,0 @@
1
- <?php defined('WYSIJA') or die('Restricted access');
2
- /*~ class.phpmailer.php
3
- .---------------------------------------------------------------------------.
4
- | Customized version of PHPMailer by Acyba |
5
- | Software: PHPMailer - PHP email class |
6
- | Version: 2.0.4 |
7
- | Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
8
- | Info: http://phpmailer.sourceforge.net |
9
- | Support: http://sourceforge.net/projects/phpmailer/ |
10
- | ------------------------------------------------------------------------- |
11
- | Author: Andy Prevost (project admininistrator) |
12
- | Author: Brent R. Matzelle (original founder) |
13
- | Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
14
- | Copyright (c) 2001-2003, Brent R. Matzelle |
15
- | ------------------------------------------------------------------------- |
16
- | License: Distributed under the Lesser General Public License (LGPL) |
17
- | http://www.gnu.org/copyleft/lesser.html |
18
- | This program is distributed in the hope that it will be useful - WITHOUT |
19
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
20
- | FITNESS FOR A PARTICULAR PURPOSE. |
21
- | ------------------------------------------------------------------------- |
22
- | We offer a number of paid services (www.codeworxtech.com): |
23
- | - Web Hosting on highly optimized fast and secure servers |
24
- | - Technology Consulting |
25
- | - Oursourcing (highly qualified programmers and graphic designers) |
26
- '---------------------------------------------------------------------------'
27
-
28
- /**
29
- * PHPMailer - PHP email transport class
30
- * @package PHPMailer
31
- * @author Andy Prevost
32
- * @copyright 2004 - 2009 Andy Prevost
33
- */
34
-
35
- class acymailingPHPMailer extends WYSIJA_OBJECT{
36
-
37
- /////////////////////////////////////////////////
38
- // PROPERTIES, PUBLIC
39
- /////////////////////////////////////////////////
40
-
41
- /**
42
- * Email priority (1 = High, 3 = Normal, 5 = low).
43
- * @var int
44
- */
45
- var $Priority = 3;
46
-
47
- /**
48
- * Sets the CharSet of the message.
49
- * @var string
50
- */
51
- var $CharSet = 'iso-8859-1';
52
-
53
- /**
54
- * Sets the Content-type of the message.
55
- * @var string
56
- */
57
- var $ContentType = 'text/plain';
58
-
59
- /**
60
- * Sets the Encoding of the message. Options for this are "8bit",
61
- * "7bit", "binary", "base64", and "quoted-printable".
62
- * @var string
63
- */
64
- var $Encoding = '8bit';
65
-
66
- /**
67
- * Holds the most recent mailer error message.
68
- * @var string
69
- */ var $ErrorInfo = '';
70
-
71
- /**
72
- * Sets the From email address for the message.
73
- * @var string
74
- */
75
- var $From = '';
76
-
77
- /**
78
- * Sets the From name of the message.
79
- * @var string
80
- */
81
- var $FromName = '';
82
-
83
- /**
84
- * Sets the Sender email (Return-Path) of the message. If not empty,
85
- * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
86
- * @var string
87
- */
88
- var $Sender = '';
89
-
90
- /**
91
- * Sets the Subject of the message.
92
- * @var string
93
- */
94
- var $Subject = '';
95
-
96
- /**
97
- * Sets the Body of the message. This can be either an HTML or text body.
98
- * If HTML then run IsHTML(true).
99
- * @var string
100
- */
101
- var $Body = '';
102
-
103
- /**
104
- * Sets the text-only body of the message. This automatically sets the
105
- * email to multipart/alternative. This body can be read by mail
106
- * clients that do not have HTML email capability such as mutt. Clients
107
- * that can read HTML will view the normal Body.
108
- * @var string
109
- */
110
- var $AltBody = '';
111
-
112
- /**
113
- * Sets word wrapping on the body of the message to a given number of
114
- * characters.
115
- * @var int
116
- */
117
- var $WordWrap = 0;
118
-
119
- /**
120
- * Method to send mail: ("mail", "sendmail", or "smtp").
121
- * @var string
122
- */
123
- var $Mailer = 'mail';
124
-
125
- /**
126
- * Sets the path of the sendmail program.
127
- * @var string
128
- */
129
- var $Sendmail = '/usr/sbin/sendmail';
130
-
131
- /**
132
- * Path to PHPMailer plugins. This is now only useful if the SMTP class
133
- * is in a different directory than the PHP include path.
134
- * @var string
135
- */
136
- var $PluginDir = '';
137
-
138
- /**
139
- * Holds PHPMailer version.
140
- * @var string
141
- */
142
- var $Version = "2.0.4";
143
-
144
- /**
145
- * Sets the email address that a reading confirmation will be sent.
146
- * @var string
147
- */
148
- var $ConfirmReadingTo = '';
149
-
150
- /**
151
- * Sets the hostname to use in Message-Id and Received headers
152
- * and as default HELO string. If empty, the value returned
153
- * by SERVER_NAME is used or 'localhost.localdomain'.
154
- * @var string
155
- */
156
- var $Hostname = '';
157
-
158
- /**
159
- * Sets the message ID to be used in the Message-Id header.
160
- * If empty, a unique id will be generated.
161
- * @var string
162
- */
163
- var $MessageID = '';
164
-
165
- /**
166
- * Used with DKIM DNS Resource Record
167
- * @var string
168
- */
169
- var $DKIM_selector = 'wys';
170
-
171
- /**
172
- * Used with DKIM DNS Resource Record
173
- * optional, in format of email address 'you@yourdomain.com'
174
- * @var string
175
- */
176
- var $DKIM_identity = '';
177
-
178
- /**
179
- * Used with DKIM DNS Resource Record
180
- * optional, in format of email address 'you@yourdomain.com'
181
- * @var string
182
- */
183
- var $DKIM_domain = '';
184
-
185
- /**
186
- * Used with DKIM DNS Resource Record
187
- * optional, in format of email address 'you@yourdomain.com'
188
- * @var string
189
- */
190
- var $DKIM_private = '';
191
-
192
- var $DKIM_passphrase = '';
193
-
194
- /////////////////////////////////////////////////
195
- // PROPERTIES FOR SMTP
196
- /////////////////////////////////////////////////
197
-
198
- /**
199
- * Sets the SMTP hosts. All hosts must be separated by a
200
- * semicolon. You can also specify a different port
201
- * for each host by using this format: [hostname:port]
202
- * (e.g. "smtp1.example.com:25;smtp2.example.com").
203
- * Hosts will be tried in order.
204
- * @var string
205
- */
206
- var $Host = 'localhost';
207
-
208
- /**
209
- * Sets the default SMTP server port.
210
- * @var int
211
- */
212
- var $Port = 25;
213
-
214
- /**
215
- * Sets the SMTP HELO of the message (Default is $Hostname).
216
- * @var string
217
- */
218
- var $Helo = '';
219
-
220
- /**
221
- * Sets connection prefix.
222
- * Options are "", "ssl" or "tls"
223
- * @var string
224
- */
225
- var $SMTPSecure = "";
226
-
227
- /**
228
- * Sets SMTP authentication. Utilizes the Username and Password variables.
229
- * @var bool
230
- */
231
- var $SMTPAuth = false;
232
-
233
- /**
234
- * Sets SMTP username.
235
- * @var string
236
- */
237
- var $Username = '';
238
-
239
- /**
240
- * Sets SMTP password.
241
- * @var string
242
- */
243
- var $Password = '';
244
-
245
- /**
246
- * Sets the SMTP server timeout in seconds. This function will not
247
- * work with the win32 version.
248
- * @var int
249
- */
250
- var $Timeout = 10;
251
-
252
- /**
253
- * Sets SMTP class debugging on or off.
254
- * @var bool
255
- */
256
- var $SMTPDebug = false;
257
-
258
- /**
259
- * Prevents the SMTP connection from being closed after each mail
260
- * sending. If this is set to true then to close the connection
261
- * requires an explicit call to SmtpClose().
262
- * @var bool
263
- */
264
- var $SMTPKeepAlive = false;
265
-
266
- /**
267
- * Provides the ability to have the TO field process individual
268
- * emails, instead of sending to entire TO addresses
269
- * @var bool
270
- */
271
- var $SingleTo = false;
272
-
273
- /////////////////////////////////////////////////
274
- // PROPERTIES, PRIVATE
275
- /////////////////////////////////////////////////
276
-
277
- var $smtp = NULL;
278
- var $to = array();
279
- var $cc = array();
280
- var $bcc = array();
281
- var $ReplyTo = array();
282
- var $attachment = array();
283
- var $CustomHeader = array();
284
- var $message_type = '';
285
- var $boundary = array();
286
- var $language = array();
287
- var $error_count = 0;
288
- var $LE = "\n";
289
- var $sign_cert_file = "";
290
- var $sign_key_file = "";
291
- var $sign_key_pass = "";
292
-
293
- /////////////////////////////////////////////////
294
- // METHODS, VARIABLES
295
- /////////////////////////////////////////////////
296
-
297
- /**
298
- * Sets message type to HTML.
299
- * @param bool $bool
300
- * @return void
301
- */
302
- function IsHTML($bool) {
303
- if($bool == true) {
304
- $this->ContentType = 'text/html';
305
- } else {
306
- $this->ContentType = 'text/plain';
307
- }
308
- }
309
-
310
- /**
311
- * Sets Mailer to send message using SMTP.
312
- * @return void
313
- */
314
- function IsSMTP() {
315
- $this->Mailer = 'smtp';
316
- }
317
-
318
- /**
319
- * Sets Mailer to send message using PHP mail() function.
320
- * @return void
321
- */
322
- function IsMail() {
323
- $this->Mailer = 'mail';
324
- }
325
-
326
- /**
327
- * Sets Mailer to send message using the $Sendmail program.
328
- * @return void
329
- */
330
- function IsSendmail() {
331
- $this->Mailer = 'sendmail';
332
- }
333
-
334
- /**
335
- * Sets Mailer to send message using the qmail MTA.
336
- * @return void
337
- */
338
- function IsQmail() {
339
- $this->Sendmail = '/var/qmail/bin/sendmail';
340
- $this->Mailer = 'sendmail';
341
- }
342
-
343
- /////////////////////////////////////////////////
344
- // METHODS, RECIPIENTS
345
- /////////////////////////////////////////////////
346
-
347
- /**
348
- * Adds a "To" address.
349
- * @param string $address
350
- * @param string $name
351
- * @return void
352
- */
353
- function AddAddress($address, $name = '') {
354
- $cur = count($this->to);
355
- $this->to[$cur][0] = trim($address);
356
- $this->to[$cur][1] = $name;
357
- }
358
-
359
- /**
360
- * Adds a "Cc" address. Note: this function works
361
- * with the SMTP mailer on win32, not with the "mail"
362
- * mailer.
363
- * @param string $address
364
- * @param string $name
365
- * @return void
366
- */
367
- function AddCC($address, $name = '') {
368
- $cur = count($this->cc);
369
- $this->cc[$cur][0] = trim($address);
370
- $this->cc[$cur][1] = $name;
371
- }
372
-
373
- /**
374
- * Adds a "Bcc" address. Note: this function works
375
- * with the SMTP mailer on win32, not with the "mail"
376
- * mailer.
377
- * @param string $address
378
- * @param string $name
379
- * @return void
380
- */
381
- function AddBCC($address, $name = '') {
382
- $cur = count($this->bcc);
383
- $this->bcc[$cur][0] = trim($address);
384
- $this->bcc[$cur][1] = $name;
385
- }
386
-
387
- /**
388
- * Adds a "Reply-To" address.
389
- * @param string $address
390
- * @param string $name
391
- * @return void
392
- */
393
- function AddReplyTo($address, $name = '') {
394
- $cur = count($this->ReplyTo);
395
- $this->ReplyTo[$cur][0] = trim($address);
396
- $this->ReplyTo[$cur][1] = $name;
397
- }
398
-
399
- /////////////////////////////////////////////////
400
- // METHODS, MAIL SENDING
401
- /////////////////////////////////////////////////
402
-
403
- /**
404
- * Creates message and assigns Mailer. If the message is
405
- * not sent successfully then it returns false. Use the ErrorInfo
406
- * variable to view description of the error.
407
- * @return bool
408
- */
409
- function Send() {
410
- $header = '';
411
- $body = '';
412
- $result = true;
413
-
414
- if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
415
- $this->SetError('provide_address');
416
- return false;
417
- }
418
-
419
- /* Set whether the message is multipart/alternative */
420
- if(!empty($this->AltBody)) {
421
- $this->ContentType = 'multipart/alternative';
422
- }
423
-
424
- $this->error_count = 0; // reset errors
425
- $this->SetMessageType();
426
- $header .= $this->CreateHeader();
427
- $body = $this->CreateBody();
428
-
429
- if(empty($body)) {
430
- return false;
431
- }
432
-
433
- // digitally sign with DKIM if enabled
434
- // we don't sign emails with DKIM if we cannot
435
- if(!empty($this->DKIM_domain) && !empty($this->DKIM_private)) {
436
- $header_dkim = $this->DKIM_Add($body);
437
- $header = str_replace("\r\n",$this->LE,$header_dkim) . $header;
438
- }
439
-
440
-
441
- /* Choose the mailer */
442
- switch($this->Mailer) {
443
- case 'sendmail':
444
- $result = $this->SendmailSend($header, $body);
445
- break;
446
- case 'smtp':
447
- $result = $this->SmtpSend($header, $body);
448
- break;
449
- case 'elasticemail' :
450
- $result = $this->elasticEmail->sendMail($this);
451
- if (!$result) $this->SetError($this->elasticEmail->error);
452
- break;
453
- case 'sendgrid' :
454
- $result = $this->sendGrid->sendMail($this);
455
- if (!$result) $this->SetError($this->sendGrid->error);
456
- break;
457
- case 'sparkpost' :
458
- $result = $this->sparkpost->send_mail($this);
459
- if ( $result !== true ) $this->error($this->sparkpost->error);
460
- break;
461
- case 'mailpoet' :
462
- $result = $this->mailpoet->send_mail($this);
463
- if ( $result !== true ) $this->error($this->mailpoet->error);
464
- break;
465
- case 'wpmail' :
466
- $to = array_filter($this->to[0]);
467
- add_filter('phpmailer_init',array($this,'wpmail_init'),90);
468
- $result = wp_mail($to[0], $this->Subject, $this->Body, $header);
469
- break;
470
- default:
471
- $result = $this->MailSend($header, $body);
472
- break;
473
- //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported'));
474
- //$result = false;
475
- //break;
476
- }
477
-
478
- return $result;
479
- }
480
-
481
- /**
482
- * Sends mail using the $Sendmail program.
483
- * @access private
484
- * @return bool
485
- */
486
- function SendmailSend($header, $body) {
487
- if ($this->Sender != '') {
488
- $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
489
- } else {
490
- $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
491
- }
492
-
493
- if(!@$mail = popen($sendmail, 'w')) {
494
- $this->SetError('execute' , $this->Sendmail);
495
- return false;
496
- }
497
-
498
- fputs($mail, $header);
499
- fputs($mail, $body);
500
-
501
- $result = pclose($mail);
502
- if (version_compare(phpversion(), '4.2.3') == -1) {
503
- $result = $result >> 8 & 0xFF;
504
- }
505
- if($result != 0) {
506
- $this->SetError('execute' , $this->Sendmail);
507
- return false;
508
- }
509
- return true;
510
- }
511
-
512
- /**
513
- * Sends mail using the PHP mail() function.
514
- * @access private
515
- * @return bool
516
- */
517
- function MailSend($header, $body) {
518
-
519
- $to = '';
520
- for($i = 0; $i < count($this->to); $i++) {
521
- if($i != 0) { $to .= ', '; }
522
- $to .= $this->AddrFormat($this->to[$i]);
523
- }
524
-
525
- $toArr = explode(',', $to);
526
-
527
- if (!empty($this->Sender) && !(bool)ini_get('safe_mode')) {
528
- //shouldnot it be -f%s ?
529
- $params = sprintf("-oi -f %s", escapeshellarg($this->Sender));
530
- $old_from = ini_get('sendmail_from');
531
- ini_set('sendmail_from', $this->Sender);
532
- if ($this->SingleTo === true && count($toArr) > 1) {
533
- foreach ($toArr as $key => $val) {
534
- $rt = mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
535
- }
536
- } else {
537
- $rt = mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
538
- }
539
- ini_set('sendmail_from', $old_from);
540
- } else {
541
- if ($this->SingleTo === true && count($toArr) > 1) {
542
- foreach ($toArr as $key => $val) {
543
- $rt = mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
544
- }
545
- } else {
546
- $rt = mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
547
- }
548
- }
549
-
550
- if(!$rt) {
551
- $this->SetError('instantiate');
552
- return false;
553
- }
554
-
555
- return true;
556
- }
557
-
558
- /**
559
- * Sends mail via SMTP using PhpSMTP (Author:
560
- * Chris Ryan). Returns bool. Returns false if there is a
561
- * bad MAIL FROM, RCPT, or DATA input.
562
- * @access private
563
- * @return bool
564
- */
565
- function SmtpSend($header, $body) {
566
- include_once(dirname(__FILE__).DS. 'class.smtp.php');
567
- $error = '';
568
- $bad_rcpt = array();
569
-
570
- if(!$this->SmtpConnect()) {
571
- return false;
572
- }
573
-
574
- $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
575
- if(!$this->smtp->Mail($smtp_from)) {
576
-
577
- $this->SetError('from_failed', $smtp_from);
578
- $this->smtp->Reset();
579
- return false;
580
- }
581
-
582
- /* Attempt to send attach all recipients */
583
- for($i = 0; $i < count($this->to); $i++) {
584
- if(!$this->smtp->Recipient($this->to[$i][0])) {
585
- $bad_rcpt[] = $this->to[$i][0];
586
- }
587
- }
588
- for($i = 0; $i < count($this->cc); $i++) {
589
- if(!$this->smtp->Recipient($this->cc[$i][0])) {
590
- $bad_rcpt[] = $this->cc[$i][0];
591
- }
592
- }
593
- for($i = 0; $i < count($this->bcc); $i++) {
594
- if(!$this->smtp->Recipient($this->bcc[$i][0])) {
595
- $bad_rcpt[] = $this->bcc[$i][0];
596
- }
597
- }
598
-
599
- if(count($bad_rcpt) > 0) { // Create error message
600
- for($i = 0; $i < count($bad_rcpt); $i++) {
601
- if($i != 0) {
602
- $error .= ', ';
603
- }
604
- $error .= $bad_rcpt[$i];
605
- }
606
-
607
- $this->SetError('recipients_failed', $error);
608
- $this->smtp->Reset();
609
- return false;
610
- }
611
-
612
- if(!$this->smtp->Data($header . $body)) {
613
- //We display a better error message for that error, it may help us to move forward in some cases...
614
- $errorInfos = empty($this->smtp->error['error']) ? 'data_not_accepted' : $this->smtp->error['error'];
615
-
616
- //Then we add additional data...
617
- if(!empty($this->smtp->error['smtp_code'])) $errorInfos .= ' '.$this->smtp->error['smtp_code'];
618
- if(!empty($this->smtp->error['smtp_msg'])) $errorInfos .= ' '.$this->smtp->error['smtp_msg'];
619
- $this->SetError($errorInfos);
620
- $this->smtp->Reset();
621
- return false;
622
- }
623
- if($this->SMTPKeepAlive == true) {
624
- $this->smtp->Reset();
625
- } else {
626
- $this->SmtpClose();
627
- }
628
-
629
- return true;
630
- }
631
-
632
- /**
633
- * Initiates a connection to an SMTP server. Returns false if the
634
- * operation failed.
635
- * @access private
636
- * @return bool
637
- */
638
- function SmtpConnect() {
639
- if($this->smtp == NULL) {
640
- $this->smtp = new acymailingSMTP();
641
- }
642
-
643
- $this->smtp->do_debug = $this->SMTPDebug;
644
- $hosts = explode(';', $this->Host);
645
- $index = 0;
646
- $connection = ($this->smtp->Connected());
647
-
648
- /* Retry while there is no connection */
649
- while($index < count($hosts) && $connection == false) {
650
- $hostinfo = array();
651
- if(preg_match('#^(.+):([0-9]+)$#i', $hosts[$index], $hostinfo)) {
652
- $host = $hostinfo[1];
653
- $port = $hostinfo[2];
654
- } else {
655
- $host = $hosts[$index];
656
- $port = $this->Port;
657
- }
658
-
659
- $tls = ($this->SMTPSecure == 'tls');
660
- $ssl = ($this->SMTPSecure == 'ssl');
661
-
662
- if($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {
663
- $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
664
- $this->smtp->Hello($hello);
665
-
666
- if($tls) {
667
- if(!$this->smtp->StartTLS()) {
668
- $this->smtp->Reset();
669
- $connection = false;
670
- break;
671
- }
672
-
673
- //We must resend HELO after tls negotiation
674
- $this->smtp->Hello($hello);
675
- }
676
-
677
- $connection = true;
678
- if($this->SMTPAuth) {
679
- if(!$this->smtp->Authenticate($this->Username, $this->Password)) {
680
- $this->SetError('authenticate');
681
- $this->smtp->Reset();
682
- $connection = false;
683
- }
684
- }
685
- }
686
- $index++;
687
- }
688
- if(!$connection) {
689
- $this->SetError('connect_host');
690
- }
691
-
692
- return $connection;
693
- }
694
-
695
- /**
696
- * Closes the active SMTP session if one exists.
697
- * @return void
698
- */
699
- function SmtpClose() {
700
- if($this->smtp != NULL) {
701
- if($this->smtp->Connected()) {
702
- $this->smtp->Quit();
703
- $this->smtp->Close();
704
- }
705
- }
706
-
707
- if(!empty($this->elasticEmail->conn)){
708
- $this->elasticEmail->close();
709
- }
710
- }
711
-
712
- /**
713
- * Sets the language for all class error messages. Returns false
714
- * if it cannot load the language file. The default language type
715
- * is English.
716
- * @param string $lang_type Type of language (e.g. Portuguese: "br")
717
- * @param string $lang_path Path to the language file directory
718
- * @access public
719
- * @return bool
720
- */
721
- function SetLanguage($lang_type, $lang_path = 'language/') {
722
-
723
- $PHPMAILER_LANG = array();
724
- $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
725
- $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
726
- $PHPMAILER_LANG["execute"] = 'Could not execute: ';
727
- $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
728
- $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
729
- $PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
730
- $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
731
- $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
732
- $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
733
- $PHPMAILER_LANG["file_access"] = 'Could not access file: ';
734
- $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
735
- $PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
736
- $PHPMAILER_LANG["signing"] = 'Signing Error: ';
737
-
738
- $this->language = $PHPMAILER_LANG;
739
-
740
- return true;
741
- }
742
-
743
- /////////////////////////////////////////////////
744
- // METHODS, MESSAGE CREATION
745
- /////////////////////////////////////////////////
746
-
747
- /**
748
- * Creates recipient headers.
749
- * @access private
750
- * @return string
751
- */
752
- function AddrAppend($type, $addr) {
753
- $addr_str = $type . ': ';
754
- $addr_str .= $this->AddrFormat($addr[0]);
755
- if(count($addr) > 1) {
756
- for($i = 1; $i < count($addr); $i++) {
757
- $addr_str .= ', ' . $this->AddrFormat($addr[$i]);
758
- }
759
- }
760
- $addr_str .= $this->LE;
761
-
762
- return $addr_str;
763
- }
764
-
765
- /**
766
- * Formats an address correctly.
767
- * @access private
768
- * @return string
769
- */
770
- function AddrFormat($addr) {
771
- if(empty($addr[1])) {
772
- $formatted = $this->SecureHeader($addr[0]);
773
- } else {
774
- $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
775
- }
776
-
777
- return $formatted;
778
- }
779
-
780
- /**
781
- * Wraps message for use with mailers that do not
782
- * automatically perform wrapping and for quoted-printable.
783
- * Original written by philippe.
784
- * @access private
785
- * @return string
786
- */
787
- function WrapText($message, $length, $qp_mode = false) {
788
- $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
789
- // If utf-8 encoding is used, we will need to make sure we don't
790
- // split multibyte characters when we wrap
791
- $is_utf8 = (strtolower($this->CharSet) == "utf-8");
792
-
793
- $message = $this->FixEOL($message);
794
- if (substr($message, -1) == $this->LE) {
795
- $message = substr($message, 0, -1);
796
- }
797
-
798
- $line = explode($this->LE, $message);
799
- $message = '';
800
- for ($i=0 ;$i < count($line); $i++) {
801
- $line_part = explode(' ', $line[$i]);
802
- $buf = '';
803
- for ($e = 0; $e<count($line_part); $e++) {
804
- $word = $line_part[$e];
805
- if ($qp_mode and (strlen($word) > $length)) {
806
- $space_left = $length - strlen($buf) - 1;
807
- if ($e != 0) {
808
- if ($space_left > 20) {
809
- $len = $space_left;
810
- if ($is_utf8) {
811
- $len = $this->UTF8CharBoundary($word, $len);
812
- } elseif (substr($word, $len - 1, 1) == "=") {
813
- $len--;
814
- } elseif (substr($word, $len - 2, 1) == "=") {
815
- $len -= 2;
816
- }
817
- $part = substr($word, 0, $len);
818
- $word = substr($word, $len);
819
- $buf .= ' ' . $part;
820
- $message .= $buf . sprintf("=%s", $this->LE);
821
- } else {
822
- $message .= $buf . $soft_break;
823
- }
824
- $buf = '';
825
- }
826
- while (strlen($word) > 0) {
827
- $len = $length;
828
- if ($is_utf8) {
829
- $len = $this->UTF8CharBoundary($word, $len);
830
- } elseif (substr($word, $len - 1, 1) == "=") {
831
- $len--;
832
- } elseif (substr($word, $len - 2, 1) == "=") {
833
- $len -= 2;
834
- }
835
- $part = substr($word, 0, $len);
836
- $word = substr($word, $len);
837
-
838
- if (strlen($word) > 0) {
839
- $message .= $part . sprintf("=%s", $this->LE);
840
- } else {
841
- $buf = $part;
842
- }
843
- }
844
- } else {
845
- $buf_o = $buf;
846
- $buf .= ($e == 0) ? $word : (' ' . $word);
847
-
848
- if (strlen($buf) > $length and $buf_o != '') {
849
- $message .= $buf_o . $soft_break;
850
- $buf = $word;
851
- }
852
- }
853
- }
854
- $message .= $buf . $this->LE;
855
- }
856
-
857
- return $message;
858
- }
859
-
860
- /**
861
- * Finds last character boundary prior to maxLength in a utf-8
862
- * quoted (printable) encoded string.
863
- * Original written by Colin Brown.
864
- * @access private
865
- * @param string $encodedText utf-8 QP text
866
- * @param int $maxLength find last character boundary prior to this length
867
- * @return int
868
- */
869
- function UTF8CharBoundary($encodedText, $maxLength) {
870
- $foundSplitPos = false;
871
- $lookBack = 3;
872
- while (!$foundSplitPos) {
873
- $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
874
- $encodedCharPos = strpos($lastChunk, "=");
875
- if ($encodedCharPos !== false) {
876
- // Found start of encoded character byte within $lookBack block.
877
- // Check the encoded byte value (the 2 chars after the '=')
878
- $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
879
- $dec = hexdec($hex);
880
- if ($dec < 128) { // Single byte character.
881
- // If the encoded char was found at pos 0, it will fit
882
- // otherwise reduce maxLength to start of the encoded char
883
- $maxLength = ($encodedCharPos == 0) ? $maxLength :
884
- $maxLength - ($lookBack - $encodedCharPos);
885
- $foundSplitPos = true;
886
- } elseif ($dec >= 192) { // First byte of a multi byte character
887
- // Reduce maxLength to split at start of character
888
- $maxLength = $maxLength - ($lookBack - $encodedCharPos);
889
- $foundSplitPos = true;
890
- } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
891
- $lookBack += 3;
892
- }
893
- } else {
894
- // No encoded character found
895
- $foundSplitPos = true;
896
- }
897
- }
898
- return $maxLength;
899
- }
900
-
901
- /**
902
- * Set the body wrapping.
903
- * @access private
904
- * @return void
905
- */
906
- function SetWordWrap() {
907
- if($this->WordWrap < 1) {
908
- return;
909
- }
910
-
911
- if(!empty($this->AltBody)) $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
912
- $this->Body = $this->WrapText($this->Body, $this->WordWrap);
913
- }
914
-
915
- /**
916
- * Assembles message header.
917
- * @access private
918
- * @return string
919
- */
920
- function CreateHeader() {
921
- $result = '';
922
-
923
- /* Set the boundaries */
924
- $uniq_id = md5(uniqid(time()));
925
- $this->boundary[1] = 'b1_' . $uniq_id;
926
- $this->boundary[2] = 'b2_' . $uniq_id;
927
- $this->boundary[3] = 'b3_' . $uniq_id;
928
-
929
- $result .= $this->HeaderLine('Date', $this->RFCDate());
930
- if($this->Sender == '') {
931
- $result .= $this->HeaderLine('Return-Path', trim($this->From));
932
- } else {
933
- $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
934
- }
935
-
936
- /* To be created automatically by mail() */
937
- if($this->Mailer != 'mail') {
938
- if(count($this->to) > 0) {
939
- $result .= $this->AddrAppend('To', $this->to);
940
- } elseif (count($this->cc) == 0) {
941
- $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
942
- }
943
- }
944
-
945
- $from = array();
946
- $from[0][0] = trim($this->From);
947
- $from[0][1] = $this->FromName;
948
- $result .= $this->AddrAppend('From', $from);
949
-
950
- /* sendmail and mail() extract Cc from the header before sending */
951
- if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) {
952
- $result .= $this->AddrAppend('Cc', $this->cc);
953
- }
954
-
955
- /* sendmail and mail() extract Bcc from the header before sending */
956
- if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
957
- $result .= $this->AddrAppend('Bcc', $this->bcc);
958
- }
959
-
960
- if(count($this->ReplyTo) > 0) {
961
- $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);
962
- }
963
-
964
- /* mail() sets the subject itself */
965
- if($this->Mailer != 'mail') {
966
- $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
967
- }
968
-
969
- if($this->MessageID != '') {
970
- $result .= $this->HeaderLine('Message-ID',$this->MessageID);
971
- } else {
972
- $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
973
- }
974
- $result .= $this->HeaderLine('X-Priority', $this->Priority);
975
- $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']');
976
-
977
- if($this->ConfirmReadingTo != '') {
978
- $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
979
- }
980
-
981
- // Add custom headers
982
- for($index = 0; $index < count($this->CustomHeader); $index++) {
983
- $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
984
- }
985
- if (!$this->sign_key_file) {
986
- $result .= $this->HeaderLine('MIME-Version', '1.0');
987
- $result .= $this->GetMailMIME();
988
- }
989
-
990
- return $result;
991
- }
992
-
993
- /**
994
- * Returns the message MIME.
995
- * @access private
996
- * @return string
997
- */
998
- function GetMailMIME() {
999
- $result = '';
1000
- switch($this->message_type) {
1001
- case 'plain':
1002
- $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
1003
- $result .= $this->TextLine('Content-Type: '.$this->ContentType.'; charset="'.$this->CharSet.'"');
1004
- break;
1005
- case 'inline':
1006
- $result .= $this->HeaderLine('Content-Type', 'multipart/related;');
1007
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1008
- break;
1009
- case 'attach':
1010
- case 'inline_attach':
1011
- case 'alt_attach':
1012
- case 'alt_inline_attach':
1013
- $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
1014
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1015
- break;
1016
- case 'alt':
1017
- case 'alt_inline':
1018
- $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1019
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1020
- break;
1021
- }
1022
-
1023
- //Added by Adrien on 11.02.2011 and then on 06 April 2011 otherwise we have 3 return char on phpMail or other functions
1024
- $result = rtrim($result,$this->LE);
1025
- if($this->Mailer != 'mail') {
1026
- $result .= $this->LE.$this->LE;
1027
- }
1028
-
1029
- return $result;
1030
- }
1031
-
1032
- /**
1033
- * Assembles the message body. Returns an empty string on failure.
1034
- * @access private
1035
- * @return string
1036
- */
1037
- function CreateBody() {
1038
- $result = '';
1039
- if ($this->sign_key_file) {
1040
- $result .= $this->GetMailMIME();
1041
- }
1042
-
1043
- $this->SetWordWrap();
1044
-
1045
- switch($this->message_type) {
1046
- case 'plain':
1047
- $result .= $this->EncodeString($this->Body, $this->Encoding);
1048
- break;
1049
- case 'inline':
1050
- $result .= $this->GetBoundary($this->boundary[1], '', '', '');
1051
- $result .= $this->EncodeString($this->Body, $this->Encoding);
1052
- $result .= $this->LE.$this->LE;
1053
- $result .= $this->AttachAll("inline", $this->boundary[1]);
1054
- break;
1055
- case 'attach':
1056
- $result .= $this->GetBoundary($this->boundary[1], '', '', '');
1057
- $result .= $this->EncodeString($this->Body, $this->Encoding);
1058
- $result .= $this->LE.$this->LE;
1059
- $result .= $this->AttachAll("attachment", $this->boundary[1]);
1060
- break;
1061
- case 'inline_attach':
1062
- $result .= $this->TextLine("--" . $this->boundary[1]);
1063
- $result .= $this->HeaderLine('Content-Type', 'multipart/related;');
1064
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
1065
- $result .= $this->LE;
1066
- $result .= $this->GetBoundary($this->boundary[2], '', '', '');
1067
- $result .= $this->EncodeString($this->Body, $this->Encoding);
1068
- $result .= $this->LE.$this->LE;
1069
- $result .= $this->AttachAll("inline", $this->boundary[2]);
1070
- $result .= $this->LE;
1071
- $result .= $this->AttachAll("attachment", $this->boundary[1]);
1072
- break;
1073
- case 'alt':
1074
- $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
1075
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
1076
- $result .= $this->LE.$this->LE;
1077
- $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
1078
- $result .= $this->EncodeString($this->Body, $this->Encoding);
1079
- $result .= $this->LE.$this->LE;
1080
- $result .= $this->EndBoundary($this->boundary[1]);
1081
- break;
1082
- case 'alt_inline':
1083
- $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
1084
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
1085
- $result .= $this->LE.$this->LE;
1086
- $result .= $this->TextLine("--" . $this->boundary[1]);
1087
- $result .= $this->HeaderLine('Content-Type', 'multipart/related;');
1088
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
1089
- $result .= $this->LE;
1090
- $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '');
1091
- $result .= $this->EncodeString($this->Body, $this->Encoding);
1092
- $result .= $this->LE.$this->LE;
1093
- $result .= $this->AttachAll("inline", $this->boundary[2]);
1094
- $result .= $this->LE;
1095
- $result .= $this->EndBoundary($this->boundary[1]);
1096
- break;
1097
- case 'alt_attach':
1098
- $result .= $this->TextLine("--" . $this->boundary[1]);
1099
- $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1100
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
1101
- $result .= $this->LE;
1102
- $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '');
1103
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
1104
- $result .= $this->LE.$this->LE;
1105
- $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '');
1106
- $result .= $this->EncodeString($this->Body, $this->Encoding);
1107
- $result .= $this->LE.$this->LE;
1108
- $result .= $this->EndBoundary($this->boundary[2]);
1109
- $result .= $this->LE;
1110
- $result .= $this->AttachAll("attachment", $this->boundary[1]);
1111
- break;
1112
- case 'alt_inline_attach':
1113
- $result .= $this->TextLine("--" . $this->boundary[1]);
1114
- $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1115
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
1116
- $result .= $this->LE;
1117
- $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '');
1118
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
1119
- $result .= $this->LE.$this->LE;
1120
- $result .= $this->TextLine("--" . $this->boundary[2]);
1121
- $result .= $this->HeaderLine('Content-Type', 'multipart/related;');
1122
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[3] . '"');
1123
- $result .= $this->LE;
1124
- $result .= $this->GetBoundary($this->boundary[3], '', 'text/html', '');
1125
- $result .= $this->EncodeString($this->Body, $this->Encoding);
1126
- $result .= $this->LE.$this->LE;
1127
- $result .= $this->AttachAll("inline", $this->boundary[3]);
1128
- $result .= $this->LE;
1129
- $result .= $this->EndBoundary($this->boundary[2]);
1130
- $result .= $this->LE;
1131
- $result .= $this->AttachAll("attachment", $this->boundary[1]);
1132
- break;
1133
- }
1134
-
1135
- if($this->IsError()) {
1136
- $result = '';
1137
- } else if ($this->sign_key_file) {
1138
- $file = tempnam("", "mail");
1139
- $fp = fopen($file, "w");
1140
- fwrite($fp, $result);
1141
- fclose($fp);
1142
- $signed = tempnam("", "signed");
1143
-
1144
- if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) {
1145
- $fp = fopen($signed, "r");
1146
- $result = fread($fp, filesize($this->sign_key_file));
1147
- $result = '';
1148
- while(!feof($fp)){
1149
- $result = $result . fread($fp, 1024);
1150
- }
1151
- fclose($fp);
1152
- } else {
1153
- $this->SetError('signing',openssl_error_string());
1154
- $result = '';
1155
- }
1156
-
1157
- unlink($file);
1158
- unlink($signed);
1159
- }
1160
-
1161
- return $result;
1162
- }
1163
-
1164
- /**
1165
- * Returns the start of a message boundary.
1166
- * @access private
1167
- */
1168
- function GetBoundary($boundary, $charSet, $contentType, $encoding) {
1169
- $result = '';
1170
- if($charSet == '') {
1171
- $charSet = $this->CharSet;
1172
- }
1173
- if($contentType == '') {
1174
- $contentType = $this->ContentType;
1175
- }
1176
- if($encoding == '') {
1177
- $encoding = $this->Encoding;
1178
- }
1179
- $result .= $this->TextLine('--' . $boundary);
1180
- $result .= sprintf("Content-Type: %s; charset=\"%s\"", $contentType, $charSet);
1181
- $result .= $this->LE;
1182
- $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
1183
- $result .= $this->LE;
1184
-
1185
- return $result;
1186
- }
1187
-
1188
- /**
1189
- * Returns the end of a message boundary.
1190
- * @access private
1191
- */
1192
- function EndBoundary($boundary) {
1193
- return $this->LE . '--' . $boundary . '--' . $this->LE;
1194
- }
1195
-
1196
- /**
1197
- * Sets the message type.
1198
- * @access private
1199
- * @return void
1200
- */
1201
- function SetMessageType() {
1202
- $this->message_type = array();
1203
- if($this->AlternativeExists()) $this->message_type[] = "alt";
1204
- if($this->InlineImageExists()) $this->message_type[] = "inline";
1205
- if($this->AttachmentExists()) $this->message_type[] = "attach";
1206
- $this->message_type = implode("_", $this->message_type);
1207
- if($this->message_type == "") $this->message_type = "plain";
1208
- }
1209
-
1210
- function AttachmentExists() {
1211
- foreach($this->attachment as $attachment) {
1212
- if ($attachment[6] == 'attachment') {
1213
- return true;
1214
- }
1215
- }
1216
- return false;
1217
- }
1218
-
1219
- function AlternativeExists() {
1220
- return strlen($this->AltBody)>0;
1221
- }
1222
-
1223
- /* Returns a formatted header line.
1224
- * @access private
1225
- * @return string
1226
- */
1227
- function HeaderLine($name, $value) {
1228
- return $name . ': ' . $value . $this->LE;
1229
- }
1230
-
1231
- /**
1232
- * Returns a formatted mail line.
1233
- * @access private
1234
- * @return string
1235
- */
1236
- function TextLine($value) {
1237
- return $value . $this->LE;
1238
- }
1239
-
1240
- /////////////////////////////////////////////////
1241
- // CLASS METHODS, ATTACHMENTS /////////////////////////////////////////////////
1242
-
1243
- /**
1244
- * Adds an attachment from a path on the filesystem.
1245
- * Returns false if the file could not be found
1246
- * or accessed.
1247
- * @param string $path Path to the attachment.
1248
- * @param string $name Overrides the attachment name.
1249
- * @param string $encoding File encoding (see $Encoding).
1250
- * @param string $type File extension (MIME) type.
1251
- * @return bool
1252
- */
1253
- function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1254
- if(!@is_file($path)) {
1255
- $this->SetError('file_access', $path);
1256
- return false;
1257
- }
1258
-
1259
- $filename = basename($path);
1260
- if($name == '') {
1261
- $name = $filename;
1262
- }
1263
-
1264
- $cur = count($this->attachment);
1265
- $this->attachment[$cur][0] = $path;
1266
- $this->attachment[$cur][1] = $filename;
1267
- $this->attachment[$cur][2] = $name;
1268
- $this->attachment[$cur][3] = $encoding;
1269
- $this->attachment[$cur][4] = $type;
1270
- $this->attachment[$cur][5] = false; // isStringAttachment
1271
- $this->attachment[$cur][6] = 'attachment';
1272
- $this->attachment[$cur][7] = 0;
1273
-
1274
- return true;
1275
- }
1276
-
1277
- /**
1278
- * Attaches all fs, string, and binary attachments to the message.
1279
- * Returns an empty string on failure.
1280
- * @access private
1281
- * @return string
1282
- */
1283
- function AttachAll($disposition_type, $boundary) {
1284
- // Return text of body
1285
- $mime = array();
1286
- $cidUniq = array();
1287
- $incl = array();
1288
-
1289
- // Add all attachments
1290
- foreach ($this->attachment as $attachment) {
1291
- // CHECK IF IT IS A VALID DISPOSITION_FILTER
1292
- if($attachment[6] == $disposition_type) {
1293
- // Check for string attachment
1294
- $bString = $attachment[5];
1295
- if ($bString) {
1296
- $string = $attachment[0];
1297
- } else {
1298
- $path = $attachment[0];
1299
- }
1300
-
1301
- $inclhash = md5(serialize($attachment));
1302
- if (in_array($inclhash, $incl)) { continue; }
1303
- $incl[] = $inclhash;
1304
- $filename = $attachment[1];
1305
- $name = $attachment[2];
1306
- $encoding = $attachment[3];
1307
- $type = $attachment[4];
1308
- $disposition = $attachment[6];
1309
- $cid = $attachment[7];
1310
- if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; }
1311
- $cidUniq[$cid] = true;
1312
-
1313
- $mime[] = sprintf("--%s%s", $boundary, $this->LE);
1314
- $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
1315
- $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
1316
-
1317
- if($disposition == 'inline') {
1318
- $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
1319
- }
1320
-
1321
- $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
1322
-
1323
- // Encode as string attachment
1324
- if($bString) {
1325
- $mime[] = $this->EncodeString($string, $encoding);
1326
- if($this->IsError()) {
1327
- return '';
1328
- }
1329
- $mime[] = $this->LE.$this->LE;
1330
- } else {
1331
- $mime[] = $this->EncodeFile($path, $encoding);
1332
- if($this->IsError()) {
1333
- return '';
1334
- }
1335
- $mime[] = $this->LE.$this->LE;
1336
- }
1337
- }
1338
- }
1339
-
1340
- $mime[] = sprintf("--%s--%s", $boundary, $this->LE);
1341
-
1342
- return implode("", $mime);
1343
- }
1344
-
1345
- /**
1346
- * Encodes attachment in requested format. Returns an
1347
- * empty string on failure.
1348
- * @access private
1349
- * @return string
1350
- */
1351
- function EncodeFile ($path, $encoding = 'base64') {
1352
- if(!@$fd = fopen($path, 'rb')) {
1353
- $this->SetError('file_open', $path);
1354
- return '';
1355
- }
1356
-
1357
- $magic_quotes = get_magic_quotes_runtime();
1358
- if(!empty($magic_quotes)) ini_set('magic_quotes_runtime', 0);
1359
- $file_buffer = fread($fd, filesize($path));
1360
- $file_buffer = $this->EncodeString($file_buffer, $encoding);
1361
- fclose($fd);
1362
- if(!empty($magic_quotes)) ini_set('magic_quotes_runtime',$magic_quotes);
1363
-
1364
-
1365
- return $file_buffer;
1366
- }
1367
-
1368
- /**
1369
- * Encodes string to requested format. Returns an
1370
- * empty string on failure.
1371
- * @access private
1372
- * @return string
1373
- */
1374
- function EncodeString ($str, $encoding = 'base64') {
1375
- $encoded = '';
1376
- switch(strtolower($encoding)) {
1377
- case 'base64':
1378
- /* chunk_split is found in PHP >= 3.0.6 */
1379
- $encoded = chunk_split(base64_encode($str), 76, $this->LE);
1380
- break;
1381
- case '7bit':
1382
- case '8bit':
1383
- $encoded = $this->FixEOL($str);
1384
- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
1385
- $encoded .= $this->LE;
1386
- break;
1387
- case 'binary':
1388
- $encoded = $str;
1389
- break;
1390
- case 'quoted-printable':
1391
- $encoded = $this->EncodeQP($str);
1392
- break;
1393
- default:
1394
- $this->SetError('encoding', $encoding);
1395
- break;
1396
- }
1397
- return $encoded;
1398
- }
1399
-
1400
- /**
1401
- * Encode a header string to best of Q, B, quoted or none.
1402
- * @access private
1403
- * @return string
1404
- */
1405
- function EncodeHeader ($str, $position = 'text') {
1406
- $x = 0;
1407
-
1408
- switch (strtolower($position)) {
1409
- case 'phrase':
1410
- if (!preg_match('/[\200-\377]/', $str)) {
1411
- /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */
1412
- $encoded = addcslashes($str, "\0..\37\177\\\"");
1413
- if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
1414
- return ($encoded);
1415
- } else {
1416
- return ("\"$encoded\"");
1417
- }
1418
- }
1419
- $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
1420
- break;
1421
- case 'comment':
1422
- $x = preg_match_all('/[()"]/', $str, $matches);
1423
- /* Fall-through */
1424
- case 'text':
1425
- default:
1426
- $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
1427
- break;
1428
- }
1429
-
1430
- if ($x == 0) {
1431
- return ($str);
1432
- }
1433
-
1434
- $maxlen = 75 - 7 - strlen($this->CharSet);
1435
- /* Try to select the encoding which should produce the shortest output */
1436
- if (strlen($str)/3 < $x) {
1437
- $encoding = 'B';
1438
- if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
1439
- // Use a custom function which correctly encodes and wraps long
1440
- // multibyte strings without breaking lines within a character
1441
- $encoded = $this->Base64EncodeWrapMB($str);
1442
- } else {
1443
- $encoded = base64_encode($str);
1444
- $maxlen -= $maxlen % 4;
1445
- $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
1446
- }
1447
- } else {
1448
- $encoding = 'Q';
1449
- $encoded = $this->EncodeQ($str, $position);
1450
- $encoded = $this->WrapText($encoded, $maxlen, true);
1451
- $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
1452
- }
1453
-
1454
- $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
1455
- $encoded = trim(str_replace("\n", $this->LE, $encoded));
1456
-
1457
- return $encoded;
1458
- }
1459
-
1460
- /**
1461
- * Checks if a string contains multibyte characters.
1462
- * @access private
1463
- * @param string $str multi-byte text to wrap encode
1464
- * @return bool
1465
- */
1466
- function HasMultiBytes($str) {
1467
- if (function_exists('mb_strlen')) {
1468
- return (strlen($str) > mb_strlen($str, $this->CharSet));
1469
- } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
1470
- return False;
1471
- }
1472
- }
1473
-
1474
- /**
1475
- * Correctly encodes and wraps long multibyte strings for mail headers
1476
- * without breaking lines within a character.
1477
- * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
1478
- * @access private
1479
- * @param string $str multi-byte text to wrap encode
1480
- * @return string
1481
- */
1482
- function Base64EncodeWrapMB($str) {
1483
- $start = "=?".$this->CharSet."?B?";
1484
- $end = "?=";
1485
- $encoded = "";
1486
-
1487
- $mb_length = mb_strlen($str, $this->CharSet);
1488
- // Each line must have length <= 75, including $start and $end
1489
- $length = 75 - strlen($start) - strlen($end);
1490
- // Average multi-byte ratio
1491
- $ratio = $mb_length / strlen($str);
1492
- // Base64 has a 4:3 ratio
1493
- $offset = $avgLength = floor($length * $ratio * .75);
1494
-
1495
- for ($i = 0; $i < $mb_length; $i += $offset) {
1496
- $lookBack = 0;
1497
-
1498
- do {
1499
- $offset = $avgLength - $lookBack;
1500
- $chunk = mb_substr($str, $i, $offset, $this->CharSet);
1501
- $chunk = base64_encode($chunk);
1502
- $lookBack++;
1503
- }
1504
- while (strlen($chunk) > $length);
1505
-
1506
- $encoded .= $chunk . $this->LE;
1507
- }
1508
-
1509
- // Chomp the last linefeed
1510
- $encoded = substr($encoded, 0, -strlen($this->LE));
1511
- return $encoded;
1512
- }
1513
-
1514
- /**
1515
- * Encode string to quoted-printable.
1516
- * @access private
1517
- * @return string
1518
- */
1519
- function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) {
1520
- $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
1521
- $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
1522
- $eol = "\r\n";
1523
- $escape = '=';
1524
- $output = '';
1525
- while( list(, $line) = each($lines) ) {
1526
- $linlen = strlen($line);
1527
- $newline = '';
1528
- for($i = 0; $i < $linlen; $i++) {
1529
- $c = substr( $line, $i, 1 );
1530
- $dec = ord( $c );
1531
- if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
1532
- $c = '=2E';
1533
- }
1534
- if ( $dec == 32 ) {
1535
- if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
1536
- $c = '=20';
1537
- } else if ( $space_conv ) {
1538
- $c = '=20';
1539
- }
1540
- } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
1541
- $h2 = floor($dec/16);
1542
- $h1 = floor($dec%16);
1543
- $c = $escape.$hex[$h2].$hex[$h1];
1544
- }
1545
- if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
1546
- $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
1547
- $newline = '';
1548
- // check if newline first character will be point or not
1549
- if ( $dec == 46 ) {
1550
- $c = '=2E';
1551
- }
1552
- }
1553
- $newline .= $c;
1554
- } // end of for
1555
- $output .= $newline.$eol;
1556
- } // end of while
1557
- return $output;
1558
- }
1559
-
1560
- /**
1561
- * Encode string to q encoding.
1562
- * @access private
1563
- * @return string
1564
- */
1565
- function EncodeQ ($str, $position = 'text') {
1566
- //There should not be any EOL in the string
1567
- $pattern = '';
1568
- $encoded = str_replace(array("\r", "\n"), '', $str);
1569
- switch (strtolower($position)) {
1570
- case 'phrase':
1571
- //RFC 2047 section 5.3
1572
- $pattern = '^A-Za-z0-9!*+\/ -';
1573
- break;
1574
- /** @noinspection PhpMissingBreakStatementInspection */
1575
- case 'comment':
1576
- //RFC 2047 section 5.2
1577
- $pattern = '\(\)"';
1578
- //intentional fall-through
1579
- //for this reason we build the $pattern without including delimiters and []
1580
- case 'text':
1581
- default:
1582
- //RFC 2047 section 5.1
1583
- //Replace every high ascii, control, =, ? and _ characters
1584
- $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
1585
- break;
1586
- }
1587
- $matches = array();
1588
- if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
1589
- //If the string contains an '=', make sure it's the first thing we replace
1590
- //so as to avoid double-encoding
1591
- $s = array_search('=', $matches[0]);
1592
- if ($s !== false) {
1593
- unset($matches[0][$s]);
1594
- array_unshift($matches[0], '=');
1595
- }
1596
- foreach (array_unique($matches[0]) as $char) {
1597
- $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
1598
- }
1599
- }
1600
- //Replace every spaces to _ (more readable than =20)
1601
- return str_replace(' ', '_', $encoded);
1602
- }
1603
-
1604
- /**
1605
- * Adds a string or binary attachment (non-filesystem) to the list.
1606
- * This method can be used to attach ascii or binary data,
1607
- * such as a BLOB record from a database.
1608
- * @param string $string String attachment data.
1609
- * @param string $filename Name of the attachment.
1610
- * @param string $encoding File encoding (see $Encoding).
1611
- * @param string $type File extension (MIME) type.
1612
- * @return void
1613
- */
1614
- function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
1615
- /* Append to $attachment array */
1616
- $cur = count($this->attachment);
1617
- $this->attachment[$cur][0] = $string;
1618
- $this->attachment[$cur][1] = $filename;
1619
- $this->attachment[$cur][2] = $filename;
1620
- $this->attachment[$cur][3] = $encoding;
1621
- $this->attachment[$cur][4] = $type;
1622
- $this->attachment[$cur][5] = true; // isString
1623
- $this->attachment[$cur][6] = 'attachment';
1624
- $this->attachment[$cur][7] = 0;
1625
- }
1626
-
1627
- /**
1628
- * Adds an embedded attachment. This can include images, sounds, and
1629
- * just about any other document. Make sure to set the $type to an
1630
- * image type. For JPEG images use "image/jpeg" and for GIF images
1631
- * use "image/gif".
1632
- * @param string $path Path to the attachment.
1633
- * @param string $cid Content ID of the attachment. Use this to identify
1634
- * the Id for accessing the image in an HTML form.
1635
- * @param string $name Overrides the attachment name.
1636
- * @param string $encoding File encoding (see $Encoding).
1637
- * @param string $type File extension (MIME) type.
1638
- * @return bool
1639
- */
1640
- function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1641
-
1642
- if(!@is_file($path)) {
1643
- $this->SetError('file_access', $path);
1644
- return false;
1645
- }
1646
-
1647
- $filename = basename($path);
1648
- if($name == '') {
1649
- $name = $filename;
1650
- }
1651
-
1652
- /* Append to $attachment array */
1653
- $cur = count($this->attachment);
1654
- $this->attachment[$cur][0] = $path;
1655
- $this->attachment[$cur][1] = $filename;
1656
- $this->attachment[$cur][2] = $name;
1657
- $this->attachment[$cur][3] = $encoding;
1658
- $this->attachment[$cur][4] = $type;
1659
- $this->attachment[$cur][5] = false;
1660
- $this->attachment[$cur][6] = 'inline';
1661
- $this->attachment[$cur][7] = $cid;
1662
-
1663
- return true;
1664
- }
1665
-
1666
- /**
1667
- * Returns true if an inline attachment is present.
1668
- * @access private
1669
- * @return bool
1670
- */
1671
- function InlineImageExists() {
1672
- $result = false;
1673
- for($i = 0; $i < count($this->attachment); $i++) {
1674
- if($this->attachment[$i][6] == 'inline') {
1675
- $result = true;
1676
- break;
1677
- }
1678
- }
1679
-
1680
- return $result;
1681
- }
1682
-
1683
- /////////////////////////////////////////////////
1684
- // CLASS METHODS, MESSAGE RESET
1685
- /////////////////////////////////////////////////
1686
-
1687
- /**
1688
- * Clears all recipients assigned in the TO array. Returns void.
1689
- * @return void
1690
- */
1691
- function ClearAddresses() {
1692
- $this->to = array();
1693
- }
1694
-
1695
- /**
1696
- * Clears all recipients assigned in the CC array. Returns void.
1697
- * @return void
1698
- */
1699
- function ClearCCs() {
1700
- $this->cc = array();
1701
- }
1702
-
1703
- /**
1704
- * Clears all recipients assigned in the BCC array. Returns void.
1705
- * @return void
1706
- */
1707
- function ClearBCCs() {
1708
- $this->bcc = array();
1709
- }
1710
-
1711
- /**
1712
- * Clears all recipients assigned in the ReplyTo array. Returns void.
1713
- * @return void
1714
- */
1715
- function ClearReplyTos() {
1716
- $this->ReplyTo = array();
1717
- }
1718
-
1719
- /**
1720
- * Clears all recipients assigned in the TO, CC and BCC
1721
- * array. Returns void.
1722
- * @return void
1723
- */
1724
- function ClearAllRecipients() {
1725
- $this->to = array();
1726
- $this->cc = array();
1727
- $this->bcc = array();
1728
- }
1729
-
1730
- /**
1731
- * Clears all previously set filesystem, string, and binary
1732
- * attachments. Returns void.
1733
- * @return void
1734
- */
1735
- function ClearAttachments() {
1736
- $this->attachment = array();
1737
- }
1738
-
1739
- /**
1740
- * Clears all custom headers. Returns void.
1741
- * @return void
1742
- */
1743
- function ClearCustomHeaders() {
1744
- $this->CustomHeader = array();
1745
- }
1746
-
1747
- /////////////////////////////////////////////////
1748
- // CLASS METHODS, MISCELLANEOUS
1749
- /////////////////////////////////////////////////
1750
-
1751
- /**
1752
- * Adds the error message to the error container.
1753
- * Returns void.
1754
- * @access private
1755
- * @return void
1756
- */
1757
- function SetError($msg) {
1758
- $this->error_count++;
1759
- $this->ErrorInfo = $msg;
1760
- }
1761
-
1762
- /**
1763
- * Returns the proper RFC 822 formatted date.
1764
- * @access private
1765
- * @return string
1766
- */
1767
- function RFCDate() {
1768
- $tz = @date('Z');
1769
- $tzs = ($tz < 0) ? '-' : '+';
1770
- $tz = abs($tz);
1771
- $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
1772
- $result = sprintf("%s %s%04d", @date('D, j M Y H:i:s'), $tzs, $tz);
1773
-
1774
- return $result;
1775
- }
1776
-
1777
- /**
1778
- * Returns the appropriate server variable. Should work with both
1779
- * PHP 4.1.0+ as well as older versions. Returns an empty string
1780
- * if nothing is found.
1781
- * @access private
1782
- * @return mixed
1783
- */
1784
- function ServerVar($varName) {
1785
- global $HTTP_SERVER_VARS;
1786
- global $HTTP_ENV_VARS;
1787
-
1788
- if(!isset($_SERVER)) {
1789
- $_SERVER = $HTTP_SERVER_VARS;
1790
- if(!isset($_SERVER['REMOTE_ADDR'])) {
1791
- $_SERVER = $HTTP_ENV_VARS; // must be Apache
1792
- }
1793
- }
1794
-
1795
- if(isset($_SERVER[$varName])) {
1796
- return $_SERVER[$varName];
1797
- } else {
1798
- return '';
1799
- }
1800
- }
1801
-
1802
- /**
1803
- * Returns the server hostname or 'localhost.localdomain' if unknown.
1804
- * @access private
1805
- * @return string
1806
- */
1807
- function ServerHostname() {
1808
- if ($this->Hostname != '') {
1809
- $result = $this->Hostname;
1810
- } elseif ($this->ServerVar('SERVER_NAME') != '') {
1811
- $result = $this->ServerVar('SERVER_NAME');
1812
- } else {
1813
- $result = 'localhost.localdomain';
1814
- }
1815
-
1816
- return $result;
1817
- }
1818
-
1819
- /**
1820
- * Returns a message in the appropriate language.
1821
- * @access private
1822
- * @return string
1823
- */
1824
- function Lang($key) {
1825
- if(count($this->language) < 1) {
1826
- $this->SetLanguage('en'); // set the default language
1827
- }
1828
-
1829
- if(isset($this->language[$key])) {
1830
- return $this->language[$key];
1831
- } else {
1832
- return 'Language string failed to load: ' . $key;
1833
- }
1834
- }
1835
-
1836
- /**
1837
- * Returns true if an error occurred.
1838
- * @return bool
1839
- */
1840
- function IsError() {
1841
- return ($this->error_count > 0);
1842
- }
1843
-
1844
- /**
1845
- * Changes every end of line from CR or LF to CRLF.
1846
- * @access private
1847
- * @return string
1848
- */
1849
- function FixEOL($str) {
1850
- $str = str_replace("\r\n", "\n", $str);
1851
- $str = str_replace("\r", "\n", $str);
1852
- $str = str_replace("\n", $this->LE, $str);
1853
- return $str;
1854
- }
1855
-
1856
- /**
1857
- * Adds a custom header.
1858
- * @return void
1859
- */
1860
- function AddCustomHeader($custom_header) {
1861
- $this->CustomHeader[] = explode(':', $custom_header, 2);
1862
- }
1863
-
1864
- /**
1865
- * Evaluates the message and returns modifications for inline images and backgrounds
1866
- * @access public
1867
- * @return $message
1868
- */
1869
- function MsgHTML($message,$basedir='') {
1870
- preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
1871
- if(isset($images[2])) {
1872
- foreach($images[2] as $i => $url) {
1873
- // do not change urls for absolute images (thanks to corvuscorax)
1874
- if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) {
1875
- $filename = basename($url);
1876
- $directory = dirname($url);
1877
- ($directory == '.')?$directory='':'';
1878
- $cid = 'cid:' . md5($filename);
1879
- $fileParts = split("\.", $filename);
1880
- $ext = $fileParts[1];
1881
- $mimeType = $this->_mime_types($ext);
1882
- if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
1883
- if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
1884
- if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
1885
- $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
1886
- }
1887
- }
1888
- }
1889
- }
1890
- $this->IsHTML(true);
1891
- $this->Body = $message;
1892
- $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
1893
- if ( !empty($textMsg) && empty($this->AltBody) ) {
1894
- $this->AltBody = html_entity_decode($textMsg);
1895
- }
1896
- if ( empty($this->AltBody) ) {
1897
- $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n";
1898
- }
1899
- }
1900
-
1901
- /**
1902
- * Gets the mime type of the embedded or inline image
1903
- * @access private
1904
- * @return mime type of ext
1905
- */
1906
- function _mime_types($ext = '') {
1907
- $mimes = array(
1908
- 'ai' => 'application/postscript',
1909
- 'aif' => 'audio/x-aiff',
1910
- 'aifc' => 'audio/x-aiff',
1911
- 'aiff' => 'audio/x-aiff',
1912
- 'avi' => 'video/x-msvideo',
1913
- 'bin' => 'application/macbinary',
1914
- 'bmp' => 'image/bmp',
1915
- 'class' => 'application/octet-stream',
1916
- 'cpt' => 'application/mac-compactpro',
1917
- 'css' => 'text/css',
1918
- 'dcr' => 'application/x-director',
1919
- 'dir' => 'application/x-director',
1920
- 'dll' => 'application/octet-stream',
1921
- 'dms' => 'application/octet-stream',
1922
- 'doc' => 'application/msword',
1923
- 'dvi' => 'application/x-dvi',
1924
- 'dxr' => 'application/x-director',
1925
- 'eml' => 'message/rfc822',
1926
- 'eps' => 'application/postscript',
1927
- 'exe' => 'application/octet-stream',
1928
- 'gif' => 'image/gif',
1929
- 'gtar' => 'application/x-gtar',
1930
- 'htm' => 'text/html',
1931
- 'html' => 'text/html',
1932
- 'jpe' => 'image/jpeg',
1933
- 'jpeg' => 'image/jpeg',
1934
- 'jpg' => 'image/jpeg',
1935
- 'hqx' => 'application/mac-binhex40',
1936
- 'js' => 'application/x-javascript',
1937
- 'lha' => 'application/octet-stream',
1938
- 'log' => 'text/plain',
1939
- 'lzh' => 'application/octet-stream',
1940
- 'mid' => 'audio/midi',
1941
- 'midi' => 'audio/midi',
1942
- 'mif' => 'application/vnd.mif',
1943
- 'mov' => 'video/quicktime',
1944
- 'movie' => 'video/x-sgi-movie',
1945
- 'mp2' => 'audio/mpeg',
1946
- 'mp3' => 'audio/mpeg',
1947
- 'mpe' => 'video/mpeg',
1948
- 'mpeg' => 'video/mpeg',
1949
- 'mpg' => 'video/mpeg',
1950
- 'mpga' => 'audio/mpeg',
1951
- 'oda' => 'application/oda',
1952
- 'pdf' => 'application/pdf',
1953
- 'php' => 'application/x-httpd-php',
1954
- 'php3' => 'application/x-httpd-php',
1955
- 'php4' => 'application/x-httpd-php',
1956
- 'phps' => 'application/x-httpd-php-source',
1957
- 'phtml' => 'application/x-httpd-php',
1958
- 'png' => 'image/png',
1959
- 'ppt' => 'application/vnd.ms-powerpoint',
1960
- 'ps' => 'application/postscript',
1961
- 'psd' => 'application/octet-stream',
1962
- 'qt' => 'video/quicktime',
1963
- 'ra' => 'audio/x-realaudio',
1964
- 'ram' => 'audio/x-pn-realaudio',
1965
- 'rm' => 'audio/x-pn-realaudio',
1966
- 'rpm' => 'audio/x-pn-realaudio-plugin',
1967
- 'rtf' => 'text/rtf',
1968
- 'rtx' => 'text/richtext',
1969
- 'rv' => 'video/vnd.rn-realvideo',
1970
- 'sea' => 'application/octet-stream',
1971
- 'shtml' => 'text/html',
1972
- 'sit' => 'application/x-stuffit',
1973
- 'so' => 'application/octet-stream',
1974
- 'smi' => 'application/smil',
1975
- 'smil' => 'application/smil',
1976
- 'swf' => 'application/x-shockwave-flash',
1977
- 'tar' => 'application/x-tar',
1978
- 'text' => 'text/plain',
1979
- 'txt' => 'text/plain',
1980
- 'tgz' => 'application/x-tar',
1981
- 'tif' => 'image/tiff',
1982
- 'tiff' => 'image/tiff',
1983
- 'wav' => 'audio/x-wav',
1984
- 'wbxml' => 'application/vnd.wap.wbxml',
1985
- 'wmlc' => 'application/vnd.wap.wmlc',
1986
- 'word' => 'application/msword',
1987
- 'xht' => 'application/xhtml+xml',
1988
- 'xhtml' => 'application/xhtml+xml',
1989
- 'xl' => 'application/excel',
1990
- 'xls' => 'application/vnd.ms-excel',
1991
- 'xml' => 'text/xml',
1992
- 'xsl' => 'text/xml',
1993
- 'zip' => 'application/zip'
1994
- );
1995
- return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
1996
- }
1997
-
1998
- /**
1999
- * Set (or reset) Class Objects (variables)
2000
- *
2001
- * Usage Example:
2002
- * $page->set('X-Priority', '3');
2003
- *
2004
- * @access public
2005
- * @param string $name Parameter Name
2006
- * @param mixed $value Parameter Value
2007
- * NOTE: will not work with arrays, there are no arrays to set/reset
2008
- */
2009
- function set ( $name, $value = '' ) {
2010
- if ( isset($this->$name) ) {
2011
- $this->$name = $value;
2012
- } else {
2013
- $this->SetError('Cannot set or reset variable ' . $name);
2014
- return false;
2015
- }
2016
- }
2017
-
2018
- /**
2019
- * Read a file from a supplied filename and return it.
2020
- *
2021
- * @access public
2022
- * @param string $filename Parameter File Name
2023
- */
2024
- function getFile($filename) {
2025
- $return = '';
2026
- if ($fp = fopen($filename, 'rb')) {
2027
- while (!feof($fp)) {
2028
- $return .= fread($fp, 1024);
2029
- }
2030
- fclose($fp);
2031
- return $return;
2032
- } else {
2033
- return false;
2034
- }
2035
- }
2036
-
2037
- /**
2038
- * Strips newlines to prevent header injection.
2039
- * @access private
2040
- * @param string $str String
2041
- * @return string
2042
- */
2043
- function SecureHeader($str) {
2044
- $str = trim($str);
2045
- $str = str_replace("\r", "", $str);
2046
- $str = str_replace("\n", "", $str);
2047
- return $str;
2048
- }
2049
-
2050
- /**
2051
- * Set the private key file and password to sign the message.
2052
- *
2053
- * @access public
2054
- * @param string $key_filename Parameter File Name
2055
- * @param string $key_pass Password for private key
2056
- */
2057
- function Sign($cert_filename, $key_filename, $key_pass) {
2058
- $this->sign_cert_file = $cert_filename;
2059
- $this->sign_key_file = $key_filename;
2060
- $this->sign_key_pass = $key_pass;
2061
- }
2062
-
2063
- /**
2064
- * Generate DKIM signature
2065
- *
2066
- * @access public
2067
- * @param string $s Header
2068
- */
2069
- function DKIM_Sign($s) {
2070
- if (!empty($this->DKIM_passphrase)) {
2071
- $privKey = openssl_pkey_get_private($this->DKIM_private,$this->DKIM_passphrase);
2072
- } else {
2073
- $privKey = $this->DKIM_private;
2074
- }
2075
- $signature = '';
2076
- if (openssl_sign($s, $signature, $privKey)) {
2077
- return base64_encode($signature);
2078
- }
2079
- }
2080
-
2081
- /**
2082
- * Generate DKIM Canonicalization Header
2083
- *
2084
- * @access public
2085
- * @param string $s Header
2086
- */
2087
- function DKIM_HeaderC($s) {
2088
- $s=preg_replace("/\r\n\s+/"," ",$s);
2089
- $lines=explode("\r\n",$s);
2090
- foreach ($lines as $key=>$line) {
2091
- list($heading,$value)=explode(":",$line,2);
2092
- $heading=strtolower($heading);
2093
- $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces
2094
- $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value
2095
- }
2096
- $s=implode("\r\n",$lines);
2097
- return $s;
2098
- }
2099
-
2100
- /**
2101
- * Generate DKIM Canonicalization Body
2102
- *
2103
- * @access public
2104
- * @param string $body Message Body
2105
- */
2106
- function DKIM_BodyC($body) {
2107
- if ($body == '') return "\r\n";
2108
- // stabilize line endings
2109
- $body=str_replace("\r\n","\n",$body);
2110
- $body=str_replace("\n","\r\n",$body);
2111
- // END stabilize line endings
2112
- while (substr($body,strlen($body)-4,4) == "\r\n\r\n") {
2113
- $body=substr($body,0,strlen($body)-2);
2114
- }
2115
- //You don't need that anymore
2116
- // if(in_array($this->message_type,array('alt','attachments','alt_attachments')) AND substr($body,0,2) != "\r\n"){
2117
- // $body = "\r\n".$body;
2118
- // }
2119
- return $body;
2120
- }
2121
-
2122
- /**
2123
- * Create the DKIM header, body, as new header
2124
- *
2125
- * @access public
2126
- * @param string $body Body
2127
- */
2128
- function DKIM_Add($body) {
2129
- $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms
2130
- $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
2131
- $DKIMquery = 'dns/txt'; // Query method
2132
- $DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2133
-
2134
- //Fix acymailing 28/02/2010: not only for the mail type, it solved an issue with smtp server and special char...
2135
- //if($this->Mailer == 'mail')...
2136
- $subject = $this->EncodeHeader($this->SecureHeader($this->Subject));
2137
-
2138
- $subjecta_header = "Subject: $subject";
2139
- $from = array();
2140
- $from[0][0] = trim($this->From);
2141
- $from[0][1] = $this->FromName;
2142
- $fromc_header = $this->AddrAppend('From', $from);
2143
- $toy_header = $this->AddrAppend('To', $this->to);
2144
-
2145
- $body = $this->DKIM_BodyC($body);
2146
- $DKIMlen = strlen($body) ; // Length of body
2147
- $DKIMb64 = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body
2148
- $ident = (empty($this->DKIM_identity))? '' : " i=" . $this->DKIM_identity . ";";
2149
- $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n".
2150
- "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . "; h=from:to:subject;\r\n".
2151
- "\td=" . $this->DKIM_domain . ";" . $ident ." bh=" . $DKIMb64 . ";\r\n".
2152
- "\tb=";
2153
- $toSign = $this->DKIM_HeaderC($fromc_header . "\r\n" . $toy_header . "\r\n" . $subjecta_header . "\r\n" . $dkimhdrs);
2154
- $signed = wordwrap($this->DKIM_Sign($toSign),60,"\r\n\t",true);
2155
- if(empty($signed)) return '';
2156
- return $dkimhdrs.$signed."\r\n";
2157
- }
2158
-
2159
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/phpmailer/class.smtp.php DELETED
@@ -1,1125 +0,0 @@
1
- <?php defined('WYSIJA') or die('Restricted access'); ?>
2
- <?php
3
- /*~ class.smtp.php
4
- .---------------------------------------------------------------------------.
5
- | Software: PHPMailer - PHP email class |
6
- | Version: 2.0.4 |
7
- | Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
8
- | Info: http://phpmailer.sourceforge.net |
9
- | Support: http://sourceforge.net/projects/phpmailer/ |
10
- | ------------------------------------------------------------------------- |
11
- | Author: Andy Prevost (project admininistrator) |
12
- | Author: Brent R. Matzelle (original founder) |
13
- | Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
14
- | Copyright (c) 2001-2003, Brent R. Matzelle |
15
- | ------------------------------------------------------------------------- |
16
- | License: Distributed under the Lesser General Public License (LGPL) |
17
- | http://www.gnu.org/copyleft/lesser.html |
18
- | This program is distributed in the hope that it will be useful - WITHOUT |
19
- | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
20
- | FITNESS FOR A PARTICULAR PURPOSE. |
21
- | ------------------------------------------------------------------------- |
22
- | We offer a number of paid services (www.codeworxtech.com): |
23
- | - Web Hosting on highly optimized fast and secure servers |
24
- | - Technology Consulting |
25
- | - Oursourcing (highly qualified programmers and graphic designers) |
26
- '---------------------------------------------------------------------------'
27
-
28
- /**
29
- * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
30
- * commands except TURN which will always return a not implemented
31
- * error. SMTP also provides some utility methods for sending mail
32
- * to an SMTP server.
33
- * @package PHPMailer
34
- * @author Chris Ryan
35
- */
36
-
37
- class acymailingSMTP
38
- {
39
- /**
40
- * SMTP server port
41
- * @var int
42
- */
43
- var $SMTP_PORT = 25;
44
-
45
- /**
46
- * SMTP reply line ending
47
- * @var string
48
- */
49
- var $CRLF = "\r\n";
50
-
51
- /**
52
- * Sets whether debugging is turned on
53
- * @var bool
54
- */
55
- var $do_debug; # the level of debug to perform
56
-
57
- /**
58
- * Sets VERP use on/off (default is off)
59
- * @var bool
60
- */
61
- var $do_verp = false;
62
-
63
- /**#@+
64
- * @access private
65
- */
66
- var $smtp_conn; # the socket to the server
67
- var $error; # error if any on the last call
68
- var $helo_rply; # the reply the server sent to us for HELO
69
- /**#@-*/
70
-
71
- /**
72
- * Initialize the class so that the data is in a known state.
73
- * @access public
74
- * @return void
75
- */
76
- function SMTP() {
77
- $this->smtp_conn = 0;
78
- $this->error = null;
79
- $this->helo_rply = null;
80
-
81
- $this->do_debug = 0;
82
- }
83
-
84
- /*************************************************************
85
- * CONNECTION FUNCTIONS *
86
- ***********************************************************/
87
-
88
- /**
89
- * Connect to the server specified on the port specified.
90
- * If the port is not specified use the default SMTP_PORT.
91
- * If tval is specified then a connection will try and be
92
- * established with the server for that number of seconds.
93
- * If tval is not specified the default is 20 seconds to
94
- * try on the connection.
95
- *
96
- * SMTP CODE SUCCESS: 220
97
- * SMTP CODE FAILURE: 421
98
- * @access public
99
- * @return bool
100
- */
101
- function Connect($host,$port=0,$tval=20) {
102
- # set the error val to null so there is no confusion
103
- $this->error = null;
104
-
105
- # make sure we are __not__ connected
106
- if($this->connected()) {
107
- # ok we are connected! what should we do?
108
- # for now we will just give an error saying we
109
- # are already connected
110
- $this->error = array("error" => "Already connected to a server");
111
- return false;
112
- }
113
-
114
- if(empty($port)) {
115
- $port = $this->SMTP_PORT;
116
- }
117
-
118
- #connect to the smtp server
119
- $this->smtp_conn = fsockopen($host, # the host of the server
120
- $port, # the port to use
121
- $errno, # error number if any
122
- $errstr, # error message if any
123
- $tval); # give up after ? secs
124
- # verify we connected properly
125
- if(empty($this->smtp_conn)) {
126
- $this->error = array("error" => "Failed to connect to server",
127
- "errno" => $errno,
128
- "errstr" => $errstr);
129
- if($this->do_debug >= 1) {
130
- echo "SMTP -> ERROR: " . $this->error["error"] .
131
- ": $errstr ($errno)" . $this->CRLF;
132
- }
133
- return false;
134
- }
135
-
136
- # sometimes the SMTP server takes a little longer to respond
137
- # so we will give it a longer timeout for the first read
138
- // Windows still does not have support for this timeout function
139
- if(substr(PHP_OS, 0, 3) != "WIN")
140
- socket_set_timeout($this->smtp_conn, $tval, 0);
141
-
142
- # get any announcement stuff
143
- $announce = $this->get_lines();
144
-
145
- # set the timeout of any socket functions at 1/10 of a second
146
- //if(function_exists("socket_set_timeout"))
147
- // socket_set_timeout($this->smtp_conn, 0, 100000);
148
-
149
- if($this->do_debug >= 2) {
150
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
151
- }
152
-
153
- return true;
154
- }
155
-
156
- /**
157
- * Performs SMTP authentication. Must be run after running the
158
- * Hello() method. Returns true if successfully authenticated.
159
- * @access public
160
- * @return bool
161
- */
162
- function Authenticate($username, $password) {
163
- // Start authentication
164
- fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
165
-
166
- $rply = $this->get_lines();
167
- $code = substr($rply,0,3);
168
-
169
- if($code != 334) {
170
- $this->error =
171
- array("error" => "AUTH not accepted from server",
172
- "smtp_code" => $code,
173
- "smtp_msg" => substr($rply,4));
174
- if($this->do_debug >= 1) {
175
- echo "SMTP -> ERROR: " . $this->error["error"] .
176
- ": " . $rply . $this->CRLF;
177
- }
178
- return false;
179
- }
180
-
181
- // Send encoded username
182
- fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
183
-
184
- $rply = $this->get_lines();
185
- $code = substr($rply,0,3);
186
-
187
- if($code != 334) {
188
- $this->error =
189
- array("error" => "Username not accepted from server",
190
- "smtp_code" => $code,
191
- "smtp_msg" => substr($rply,4));
192
- if($this->do_debug >= 1) {
193
- echo "SMTP -> ERROR: " . $this->error["error"] .
194
- ": " . $rply . $this->CRLF;
195
- }
196
- return false;
197
- }
198
-
199
- // Send encoded password
200
- fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
201
-
202
- $rply = $this->get_lines();
203
- $code = substr($rply,0,3);
204
-
205
- if($code != 235) {
206
- $this->error =
207
- array("error" => "Password not accepted from server",
208
- "smtp_code" => $code,
209
- "smtp_msg" => substr($rply,4));
210
- if($this->do_debug >= 1) {
211
- echo "SMTP -> ERROR: " . $this->error["error"] .
212
- ": " . $rply . $this->CRLF;
213
- }
214
- return false;
215
- }
216
-
217
- return true;
218
- }
219
-
220
- /**
221
- * Returns true if connected to a server otherwise false
222
- * @access private
223
- * @return bool
224
- */
225
- function Connected() {
226
- if(!empty($this->smtp_conn)) {
227
- $sock_status = socket_get_status($this->smtp_conn);
228
- if($sock_status["eof"]) {
229
- # hmm this is an odd situation... the socket is
230
- # valid but we are not connected anymore
231
- if($this->do_debug >= 1) {
232
- echo "SMTP -> NOTICE:" . $this->CRLF .
233
- "EOF caught while checking if connected";
234
- }
235
- $this->Close();
236
- return false;
237
- }
238
- return true; # everything looks good
239
- }
240
- return false;
241
- }
242
-
243
- /**
244
- * Closes the socket and cleans up the state of the class.
245
- * It is not considered good to use this function without
246
- * first trying to use QUIT.
247
- * @access public
248
- * @return void
249
- */
250
- function Close() {
251
- $this->error = null; # so there is no confusion
252
- $this->helo_rply = null;
253
- if(!empty($this->smtp_conn)) {
254
- # close the connection and cleanup
255
- fclose($this->smtp_conn);
256
- $this->smtp_conn = 0;
257
- }
258
- }
259
-
260
- /***************************************************************
261
- * SMTP COMMANDS *
262
- *************************************************************/
263
-
264
- /**
265
- * Issues a data command and sends the msg_data to the server
266
- * finializing the mail transaction. $msg_data is the message
267
- * that is to be send with the headers. Each header needs to be
268
- * on a single line followed by a <CRLF> with the message headers
269
- * and the message body being seperated by and additional <CRLF>.
270
- *
271
- * Implements rfc 821: DATA <CRLF>
272
- *
273
- * SMTP CODE INTERMEDIATE: 354
274
- * [data]
275
- * <CRLF>.<CRLF>
276
- * SMTP CODE SUCCESS: 250
277
- * SMTP CODE FAILURE: 552,554,451,452
278
- * SMTP CODE FAILURE: 451,554
279
- * SMTP CODE ERROR : 500,501,503,421
280
- * @access public
281
- * @return bool
282
- */
283
- function Data($msg_data) {
284
- $this->error = null; # so no confusion is caused
285
-
286
- if(!$this->connected()) {
287
- $this->error = array(
288
- "error" => "Called Data() without being connected");
289
- return false;
290
- }
291
-
292
- fputs($this->smtp_conn,"DATA" . $this->CRLF);
293
-
294
- $rply = $this->get_lines();
295
- $code = substr($rply,0,3);
296
-
297
- if($this->do_debug >= 2) {
298
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
299
- }
300
-
301
- if($code != 354) {
302
- $this->error =
303
- array("error" => "DATA command not accepted from server",
304
- "smtp_code" => $code,
305
- "smtp_msg" => substr($rply,4));
306
- if($this->do_debug >= 1) {
307
- echo "SMTP -> ERROR: " . $this->error["error"] .
308
- ": " . $rply . $this->CRLF;
309
- }
310
- return false;
311
- }
312
-
313
- # the server is ready to accept data!
314
- # according to rfc 821 we should not send more than 1000
315
- # including the CRLF
316
- # characters on a single line so we will break the data up
317
- # into lines by \r and/or \n then if needed we will break
318
- # each of those into smaller lines to fit within the limit.
319
- # in addition we will be looking for lines that start with
320
- # a period '.' and append and additional period '.' to that
321
- # line. NOTE: this does not count towards are limit.
322
-
323
- # normalize the line breaks so we know the explode works
324
- $msg_data = str_replace("\r\n","\n",$msg_data);
325
- $msg_data = str_replace("\r","\n",$msg_data);
326
- $lines = explode("\n",$msg_data);
327
-
328
- # we need to find a good way to determine is headers are
329
- # in the msg_data or if it is a straight msg body
330
- # currently I am assuming rfc 822 definitions of msg headers
331
- # and if the first field of the first line (':' sperated)
332
- # does not contain a space then it _should_ be a header
333
- # and we can process all lines before a blank "" line as
334
- # headers.
335
- $field = substr($lines[0],0,strpos($lines[0],":"));
336
- $in_headers = false;
337
- if(!empty($field) && !strstr($field," ")) {
338
- $in_headers = true;
339
- }
340
-
341
- $max_line_length = 998; # used below; set here for ease in change
342
-
343
- while(list(,$line) = @each($lines)) {
344
- $lines_out = array();
345
- if($line == "" && $in_headers) {
346
- $in_headers = false;
347
- }
348
- # ok we need to break this line up into several
349
- # smaller lines
350
- while(strlen($line) > $max_line_length) {
351
- $pos = strrpos(substr($line,0,$max_line_length)," ");
352
-
353
- # Patch to fix DOS attack
354
- if(!$pos) {
355
- $pos = $max_line_length - 1;
356
- }
357
-
358
- $lines_out[] = substr($line,0,$pos);
359
- $line = substr($line,$pos + 1);
360
- # if we are processing headers we need to
361
- # add a LWSP-char to the front of the new line
362
- # rfc 822 on long msg headers
363
- if($in_headers) {
364
- $line = "\t" . $line;
365
- }
366
- }
367
- $lines_out[] = $line;
368
-
369
- # now send the lines to the server
370
- while(list(,$line_out) = @each($lines_out)) {
371
- if(strlen($line_out) > 0)
372
- {
373
- if(substr($line_out, 0, 1) == ".") {
374
- $line_out = "." . $line_out;
375
- }
376
- }
377
- fputs($this->smtp_conn,$line_out . $this->CRLF);
378
- }
379
- }
380
-
381
- # ok all the message data has been sent so lets get this
382
- # over with aleady
383
- fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
384
-
385
- $rply = $this->get_lines();
386
- $code = substr($rply,0,3);
387
-
388
- if($this->do_debug >= 2) {
389
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
390
- }
391
- /*TODO add error message*/
392
- if($code != 250) {
393
- $this->error =
394
- array("error" => "DATA not accepted from server",
395
- "smtp_code" => $code,
396
- "smtp_msg" => substr($rply,4));
397
- if($this->do_debug >= 1) {
398
- echo "SMTP -> ERROR: " . $this->error["error"] .
399
- ": " . $rply . $this->CRLF;
400
- }
401
- return false;
402
- }
403
- return true;
404
- }
405
-
406
- /**
407
- * Expand takes the name and asks the server to list all the
408
- * people who are members of the _list_. Expand will return
409
- * back and array of the result or false if an error occurs.
410
- * Each value in the array returned has the format of:
411
- * [ <full-name> <sp> ] <path>
412
- * The definition of <path> is defined in rfc 821
413
- *
414
- * Implements rfc 821: EXPN <SP> <string> <CRLF>
415
- *
416
- * SMTP CODE SUCCESS: 250
417
- * SMTP CODE FAILURE: 550
418
- * SMTP CODE ERROR : 500,501,502,504,421
419
- * @access public
420
- * @return string array
421
- */
422
- function Expand($name) {
423
- $this->error = null; # so no confusion is caused
424
-
425
- if(!$this->connected()) {
426
- $this->error = array(
427
- "error" => "Called Expand() without being connected");
428
- return false;
429
- }
430
-
431
- fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
432
-
433
- $rply = $this->get_lines();
434
- $code = substr($rply,0,3);
435
-
436
- if($this->do_debug >= 2) {
437
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
438
- }
439
-
440
- if($code != 250) {
441
- $this->error =
442
- array("error" => "EXPN not accepted from server",
443
- "smtp_code" => $code,
444
- "smtp_msg" => substr($rply,4));
445
- if($this->do_debug >= 1) {
446
- echo "SMTP -> ERROR: " . $this->error["error"] .
447
- ": " . $rply . $this->CRLF;
448
- }
449
- return false;
450
- }
451
-
452
- # parse the reply and place in our array to return to user
453
- $entries = explode($this->CRLF,$rply);
454
- while(list(,$l) = @each($entries)) {
455
- $list[] = substr($l,4);
456
- }
457
-
458
- return $list;
459
- }
460
-
461
- /**
462
- * Sends the HELO command to the smtp server.
463
- * This makes sure that we and the server are in
464
- * the same known state.
465
- *
466
- * Implements from rfc 821: HELO <SP> <domain> <CRLF>
467
- *
468
- * SMTP CODE SUCCESS: 250
469
- * SMTP CODE ERROR : 500, 501, 504, 421
470
- * @access public
471
- * @return bool
472
- */
473
- function Hello($host="") {
474
- $this->error = null; # so no confusion is caused
475
-
476
- if(!$this->connected()) {
477
- $this->error = array(
478
- "error" => "Called Hello() without being connected");
479
- return false;
480
- }
481
-
482
- # if a hostname for the HELO was not specified determine
483
- # a suitable one to send
484
- if(empty($host)) {
485
- # we need to determine some sort of appopiate default
486
- # to send to the server
487
- $host = "localhost";
488
- }
489
-
490
- // Send extended hello first (RFC 2821)
491
- if(!$this->SendHello("EHLO", $host))
492
- {
493
- if(!$this->SendHello("HELO", $host))
494
- return false;
495
- }
496
-
497
- return true;
498
- }
499
-
500
- /**
501
- * Sends a HELO/EHLO command.
502
- * @access private
503
- * @return bool
504
- */
505
- function SendHello($hello, $host) {
506
- fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
507
-
508
- $rply = $this->get_lines();
509
- $code = substr($rply,0,3);
510
-
511
- if($this->do_debug >= 2) {
512
- echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
513
- }
514
-
515
- if($code != 250) {
516
- $this->error =
517
- array("error" => $hello . " not accepted from server",
518
- "smtp_code" => $code,
519
- "smtp_msg" => substr($rply,4));
520
- if($this->do_debug >= 1) {
521
- echo "SMTP -> ERROR: " . $this->error["error"] .
522
- ": " . $rply . $this->CRLF;
523
- }
524
- return false;
525
- }
526
-
527
- $this->helo_rply = $rply;
528
-
529
- return true;
530
- }
531
-
532
- /**
533
- * Gets help information on the keyword specified. If the keyword
534
- * is not specified then returns generic help, ussually contianing
535
- * A list of keywords that help is available on. This function
536
- * returns the results back to the user. It is up to the user to
537
- * handle the returned data. If an error occurs then false is
538
- * returned with $this->error set appropiately.
539
- *
540
- * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
541
- *
542
- * SMTP CODE SUCCESS: 211,214
543
- * SMTP CODE ERROR : 500,501,502,504,421
544
- * @access public
545
- * @return string
546
- */
547
- function Help($keyword="") {
548
- $this->error = null; # to avoid confusion
549
-
550
- if(!$this->connected()) {
551
- $this->error = array(
552
- "error" => "Called Help() without being connected");
553
- return false;
554
- }
555
-
556
- $extra = "";
557
- if(!empty($keyword)) {
558
- $extra = " " . $keyword;
559
- }
560
-
561
- fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
562
-
563
- $rply = $this->get_lines();
564
- $code = substr($rply,0,3);
565
-
566
- if($this->do_debug >= 2) {
567
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
568
- }
569
-
570
- if($code != 211 && $code != 214) {
571
- $this->error =
572
- array("error" => "HELP not accepted from server",
573
- "smtp_code" => $code,
574
- "smtp_msg" => substr($rply,4));
575
- if($this->do_debug >= 1) {
576
- echo "SMTP -> ERROR: " . $this->error["error"] .
577
- ": " . $rply . $this->CRLF;
578
- }
579
- return false;
580
- }
581
-
582
- return $rply;
583
- }
584
-
585
- /**
586
- * Starts a mail transaction from the email address specified in
587
- * $from. Returns true if successful or false otherwise. If True
588
- * the mail transaction is started and then one or more Recipient
589
- * commands may be called followed by a Data command.
590
- *
591
- * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
592
- *
593
- * SMTP CODE SUCCESS: 250
594
- * SMTP CODE SUCCESS: 552,451,452
595
- * SMTP CODE SUCCESS: 500,501,421
596
- * @access public
597
- * @return bool
598
- */
599
- function Mail($from) {
600
- $this->error = null; # so no confusion is caused
601
-
602
- if(!$this->connected()) {
603
- $this->error = array(
604
- "error" => "Called Mail() without being connected");
605
- return false;
606
- }
607
-
608
- $useVerp = ($this->do_verp ? "XVERP" : "");
609
- fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
610
-
611
- $rply = $this->get_lines();
612
- $code = substr($rply,0,3);
613
-
614
- if($this->do_debug >= 2) {
615
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
616
- }
617
-
618
- if($code != 250) {
619
- $this->error =
620
- array("error" => "MAIL not accepted from server",
621
- "smtp_code" => $code,
622
- "smtp_msg" => substr($rply,4));
623
- if($this->do_debug >= 1) {
624
- echo "SMTP -> ERROR: " . $this->error["error"] .
625
- ": " . $rply . $this->CRLF;
626
- }
627
- return false;
628
- }
629
- return true;
630
- }
631
-
632
- /**
633
- * Sends the command NOOP to the SMTP server.
634
- *
635
- * Implements from rfc 821: NOOP <CRLF>
636
- *
637
- * SMTP CODE SUCCESS: 250
638
- * SMTP CODE ERROR : 500, 421
639
- * @access public
640
- * @return bool
641
- */
642
- function Noop() {
643
- $this->error = null; # so no confusion is caused
644
-
645
- if(!$this->connected()) {
646
- $this->error = array(
647
- "error" => "Called Noop() without being connected");
648
- return false;
649
- }
650
-
651
- fputs($this->smtp_conn,"NOOP" . $this->CRLF);
652
-
653
- $rply = $this->get_lines();
654
- $code = substr($rply,0,3);
655
-
656
- if($this->do_debug >= 2) {
657
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
658
- }
659
-
660
- if($code != 250) {
661
- $this->error =
662
- array("error" => "NOOP not accepted from server",
663
- "smtp_code" => $code,
664
- "smtp_msg" => substr($rply,4));
665
- if($this->do_debug >= 1) {
666
- echo "SMTP -> ERROR: " . $this->error["error"] .
667
- ": " . $rply . $this->CRLF;
668
- }
669
- return false;
670
- }
671
- return true;
672
- }
673
-
674
- /**
675
- * Sends the quit command to the server and then closes the socket
676
- * if there is no error or the $close_on_error argument is true.
677
- *
678
- * Implements from rfc 821: QUIT <CRLF>
679
- *
680
- * SMTP CODE SUCCESS: 221
681
- * SMTP CODE ERROR : 500
682
- * @access public
683
- * @return bool
684
- */
685
- function Quit($close_on_error=true) {
686
- $this->error = null; # so there is no confusion
687
-
688
- if(!$this->connected()) {
689
- $this->error = array(
690
- "error" => "Called Quit() without being connected");
691
- return false;
692
- }
693
-
694
- # send the quit command to the server
695
- fputs($this->smtp_conn,"quit" . $this->CRLF);
696
-
697
- # get any good-bye messages
698
- $byemsg = $this->get_lines();
699
-
700
- if($this->do_debug >= 2) {
701
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
702
- }
703
-
704
- $rval = true;
705
- $e = null;
706
-
707
- $code = substr($byemsg,0,3);
708
- if($code != 221) {
709
- # use e as a tmp var cause Close will overwrite $this->error
710
- $e = array("error" => "SMTP server rejected quit command",
711
- "smtp_code" => $code,
712
- "smtp_rply" => substr($byemsg,4));
713
- $rval = false;
714
- if($this->do_debug >= 1) {
715
- echo "SMTP -> ERROR: " . $e["error"] . ": " .
716
- $byemsg . $this->CRLF;
717
- }
718
- }
719
-
720
- if(empty($e) || $close_on_error) {
721
- $this->Close();
722
- }
723
-
724
- return $rval;
725
- }
726
-
727
- /**
728
- * Sends the command RCPT to the SMTP server with the TO: argument of $to.
729
- * Returns true if the recipient was accepted false if it was rejected.
730
- *
731
- * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
732
- *
733
- * SMTP CODE SUCCESS: 250,251
734
- * SMTP CODE FAILURE: 550,551,552,553,450,451,452
735
- * SMTP CODE ERROR : 500,501,503,421
736
- * @access public
737
- * @return bool
738
- */
739
- function Recipient($to) {
740
- $this->error = null; # so no confusion is caused
741
-
742
- if(!$this->connected()) {
743
- $this->error = array(
744
- "error" => "Called Recipient() without being connected");
745
- return false;
746
- }
747
-
748
- fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
749
-
750
- $rply = $this->get_lines();
751
- $code = substr($rply,0,3);
752
-
753
- if($this->do_debug >= 2) {
754
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
755
- }
756
-
757
- if($code != 250 && $code != 251) {
758
- $this->error =
759
- array("error" => "RCPT not accepted from server",
760
- "smtp_code" => $code,
761
- "smtp_msg" => substr($rply,4));
762
- if($this->do_debug >= 1) {
763
- echo "SMTP -> ERROR: " . $this->error["error"] .
764
- ": " . $rply . $this->CRLF;
765
- }
766
- return false;
767
- }
768
- return true;
769
- }
770
-
771
- /**
772
- * Sends the RSET command to abort and transaction that is
773
- * currently in progress. Returns true if successful false
774
- * otherwise.
775
- *
776
- * Implements rfc 821: RSET <CRLF>
777
- *
778
- * SMTP CODE SUCCESS: 250
779
- * SMTP CODE ERROR : 500,501,504,421
780
- * @access public
781
- * @return bool
782
- */
783
- function Reset() {
784
- $this->error = null; # so no confusion is caused
785
-
786
- if(!$this->connected()) {
787
- $this->error = array(
788
- "error" => "Called Reset() without being connected");
789
- return false;
790
- }
791
-
792
- fputs($this->smtp_conn,"RSET" . $this->CRLF);
793
-
794
- $rply = $this->get_lines();
795
- $code = substr($rply,0,3);
796
-
797
- if($this->do_debug >= 2) {
798
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
799
- }
800
-
801
- if($code != 250) {
802
- $this->error =
803
- array("error" => "RSET failed",
804
- "smtp_code" => $code,
805
- "smtp_msg" => substr($rply,4));
806
- if($this->do_debug >= 1) {
807
- echo "SMTP -> ERROR: " . $this->error["error"] .
808
- ": " . $rply . $this->CRLF;
809
- }
810
- return false;
811
- }
812
-
813
- return true;
814
- }
815
-
816
- /**
817
- * Starts a mail transaction from the email address specified in
818
- * $from. Returns true if successful or false otherwise. If True
819
- * the mail transaction is started and then one or more Recipient
820
- * commands may be called followed by a Data command. This command
821
- * will send the message to the users terminal if they are logged
822
- * in.
823
- *
824
- * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
825
- *
826
- * SMTP CODE SUCCESS: 250
827
- * SMTP CODE SUCCESS: 552,451,452
828
- * SMTP CODE SUCCESS: 500,501,502,421
829
- * @access public
830
- * @return bool
831
- */
832
- function Send($from) {
833
- $this->error = null; # so no confusion is caused
834
-
835
- if(!$this->connected()) {
836
- $this->error = array(
837
- "error" => "Called Send() without being connected");
838
- return false;
839
- }
840
-
841
- fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
842
-
843
- $rply = $this->get_lines();
844
- $code = substr($rply,0,3);
845
-
846
- if($this->do_debug >= 2) {
847
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
848
- }
849
-
850
- if($code != 250) {
851
- $this->error =
852
- array("error" => "SEND not accepted from server",
853
- "smtp_code" => $code,
854
- "smtp_msg" => substr($rply,4));
855
- if($this->do_debug >= 1) {
856
- echo "SMTP -> ERROR: " . $this->error["error"] .
857
- ": " . $rply . $this->CRLF;
858
- }
859
- return false;
860
- }
861
- return true;
862
- }
863
-
864
- /**
865
- * Starts a mail transaction from the email address specified in
866
- * $from. Returns true if successful or false otherwise. If True
867
- * the mail transaction is started and then one or more Recipient
868
- * commands may be called followed by a Data command. This command
869
- * will send the message to the users terminal if they are logged
870
- * in and send them an email.
871
- *
872
- * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
873
- *
874
- * SMTP CODE SUCCESS: 250
875
- * SMTP CODE SUCCESS: 552,451,452
876
- * SMTP CODE SUCCESS: 500,501,502,421
877
- * @access public
878
- * @return bool
879
- */
880
- function SendAndMail($from) {
881
- $this->error = null; # so no confusion is caused
882
-
883
- if(!$this->connected()) {
884
- $this->error = array(
885
- "error" => "Called SendAndMail() without being connected");
886
- return false;
887
- }
888
-
889
- fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
890
-
891
- $rply = $this->get_lines();
892
- $code = substr($rply,0,3);
893
-
894
- if($this->do_debug >= 2) {
895
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
896
- }
897
-
898
- if($code != 250) {
899
- $this->error =
900
- array("error" => "SAML not accepted from server",
901
- "smtp_code" => $code,
902
- "smtp_msg" => substr($rply,4));
903
- if($this->do_debug >= 1) {
904
- echo "SMTP -> ERROR: " . $this->error["error"] .
905
- ": " . $rply . $this->CRLF;
906
- }
907
- return false;
908
- }
909
- return true;
910
- }
911
-
912
- /**
913
- * Starts a mail transaction from the email address specified in
914
- * $from. Returns true if successful or false otherwise. If True
915
- * the mail transaction is started and then one or more Recipient
916
- * commands may be called followed by a Data command. This command
917
- * will send the message to the users terminal if they are logged
918
- * in or mail it to them if they are not.
919
- *
920
- * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
921
- *
922
- * SMTP CODE SUCCESS: 250
923
- * SMTP CODE SUCCESS: 552,451,452
924
- * SMTP CODE SUCCESS: 500,501,502,421
925
- * @access public
926
- * @return bool
927
- */
928
- function SendOrMail($from) {
929
- $this->error = null; # so no confusion is caused
930
-
931
- if(!$this->connected()) {
932
- $this->error = array(
933
- "error" => "Called SendOrMail() without being connected");
934
- return false;
935
- }
936
-
937
- fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
938
-
939
- $rply = $this->get_lines();
940
- $code = substr($rply,0,3);
941
-
942
- if($this->do_debug >= 2) {
943
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
944
- }
945
-
946
- if($code != 250) {
947
- $this->error =
948
- array("error" => "SOML not accepted from server",
949
- "smtp_code" => $code,
950
- "smtp_msg" => substr($rply,4));
951
- if($this->do_debug >= 1) {
952
- echo "SMTP -> ERROR: " . $this->error["error"] .
953
- ": " . $rply . $this->CRLF;
954
- }
955
- return false;
956
- }
957
- return true;
958
- }
959
-
960
- /**
961
- * This is an optional command for SMTP that this class does not
962
- * support. This method is here to make the RFC821 Definition
963
- * complete for this class and __may__ be implimented in the future
964
- *
965
- * Implements from rfc 821: TURN <CRLF>
966
- *
967
- * SMTP CODE SUCCESS: 250
968
- * SMTP CODE FAILURE: 502
969
- * SMTP CODE ERROR : 500, 503
970
- * @access public
971
- * @return bool
972
- */
973
- function Turn() {
974
- $this->error = array("error" => "This method, TURN, of the SMTP ".
975
- "is not implemented");
976
- if($this->do_debug >= 1) {
977
- echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
978
- }
979
- return false;
980
- }
981
-
982
- /**
983
- * Verifies that the name is recognized by the server.
984
- * Returns false if the name could not be verified otherwise
985
- * the response from the server is returned.
986
- *
987
- * Implements rfc 821: VRFY <SP> <string> <CRLF>
988
- *
989
- * SMTP CODE SUCCESS: 250,251
990
- * SMTP CODE FAILURE: 550,551,553
991
- * SMTP CODE ERROR : 500,501,502,421
992
- * @access public
993
- * @return int
994
- */
995
- function Verify($name) {
996
- $this->error = null; # so no confusion is caused
997
-
998
- if(!$this->connected()) {
999
- $this->error = array(
1000
- "error" => "Called Verify() without being connected");
1001
- return false;
1002
- }
1003
-
1004
- fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
1005
-
1006
- $rply = $this->get_lines();
1007
- $code = substr($rply,0,3);
1008
-
1009
- if($this->do_debug >= 2) {
1010
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
1011
- }
1012
-
1013
- if($code != 250 && $code != 251) {
1014
- $this->error =
1015
- array("error" => "VRFY failed on name '$name'",
1016
- "smtp_code" => $code,
1017
- "smtp_msg" => substr($rply,4));
1018
- if($this->do_debug >= 1) {
1019
- echo "SMTP -> ERROR: " . $this->error["error"] .
1020
- ": " . $rply . $this->CRLF;
1021
- }
1022
- return false;
1023
- }
1024
- return $rply;
1025
- }
1026
-
1027
- /*******************************************************************
1028
- * INTERNAL FUNCTIONS *
1029
- ******************************************************************/
1030
-
1031
- /**
1032
- * Read in as many lines as possible
1033
- * either before eof or socket timeout occurs on the operation.
1034
- * With SMTP we can tell if we have more lines to read if the
1035
- * 4th character is '-' symbol. If it is a space then we don't
1036
- * need to read anything else.
1037
- * @access private
1038
- * @return string
1039
- */
1040
-
1041
- function get_lines() {
1042
- $data = "";
1043
- while(is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
1044
- $str = @fgets($this->smtp_conn,515);
1045
- if($this->do_debug >= 4) {
1046
- echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF;
1047
- echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF;
1048
- }
1049
- $data .= $str;
1050
- if($this->do_debug >= 4) {
1051
- echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
1052
- }
1053
- // if 4th character is a space, we are done reading, break the loop
1054
- if(substr($str,3,1) == " ") { break; }
1055
- }
1056
- return $data;
1057
- }
1058
- /*function get_lines() {
1059
- $data = "";
1060
- while($str = @fgets($this->smtp_conn,515)) {
1061
- if($this->do_debug >= 4) {
1062
- echo "SMTP -> get_lines(): \$data was \"$data\"" .
1063
- $this->CRLF;
1064
- echo "SMTP -> get_lines(): \$str is \"$str\"" .
1065
- $this->CRLF;
1066
- }
1067
- $data .= $str;
1068
- if($this->do_debug >= 4) {
1069
- echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
1070
- }
1071
- # if the 4th character is a space then we are done reading
1072
- # so just break the loop
1073
- if(substr($str,3,1) == " ") { break; }
1074
- }
1075
- return $data;
1076
- }*/
1077
-
1078
- /**
1079
- * Initiate a TLS communication with the server.
1080
- *
1081
- * SMTP CODE 220 Ready to start TLS
1082
- * SMTP CODE 501 Syntax error (no parameters allowed)
1083
- * SMTP CODE 454 TLS not available due to temporary reason
1084
- * @access public
1085
- * @return bool success
1086
- */
1087
- function StartTLS() {
1088
- $this->error = null; # to avoid confusion
1089
-
1090
- stream_context_set_option($this->smtp_conn, "ssl", "verify_peer", false);
1091
-
1092
- if(!$this->connected()) {
1093
- $this->error = array("error" => "Called StartTLS() without being connected");
1094
- return false;
1095
- }
1096
-
1097
- fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
1098
-
1099
- $rply = $this->get_lines();
1100
- $code = substr($rply,0,3);
1101
-
1102
- if($this->do_debug >= 2) {
1103
- echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
1104
- }
1105
-
1106
- if($code != 220) {
1107
- $this->error =
1108
- array("error" => "STARTTLS not accepted from server",
1109
- "smtp_code" => $code,
1110
- "smtp_msg" => substr($rply,4));
1111
- if($this->do_debug >= 1) {
1112
- echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
1113
- }
1114
- return false;
1115
- }
1116
-
1117
- //Begin encrypted connection
1118
- if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
1119
- return false;
1120
- }
1121
-
1122
- return true;
1123
- }
1124
-
1125
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: MailPoet Newsletters
4
  Plugin URI: http://www.mailpoet.com/
5
  Description: Create and send newsletters or automated emails. Capture subscribers with a widget. Import and manage your lists. MailPoet is a sweet plugin maintained and supported with love.
6
- Version: 2.7.6
7
  Author: MailPoet
8
  Author URI: http://www.mailpoet.com/
9
  License: GPLv2 or later
3
  Plugin Name: MailPoet Newsletters
4
  Plugin URI: http://www.mailpoet.com/
5
  Description: Create and send newsletters or automated emails. Capture subscribers with a widget. Import and manage your lists. MailPoet is a sweet plugin maintained and supported with love.
6
+ Version: 2.7.8
7
  Author: MailPoet
8
  Author URI: http://www.mailpoet.com/
9
  License: GPLv2 or later
js/admin-config-settings.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){function i(){e("#manage_subscriptions").attr("checked")?e(".manage_subscriptions").fadeIn():e(".manage_subscriptions").fadeOut()}function n(i){null===i?e.each(e(".page_select"),function(){e("#"+e(this).attr("id")+"-links-"+e(this).val()).fadeIn()}):(id_section="#"+e(i).attr("id")+"-links",e(id_section+" span").hide(),e(id_section+"-"+e(i).val()).fadeIn())}function t(){switch(e("#sending-method-smtp").attr("checked")&&(e('#smtp-port, #smtp-secure, #smtp-login, #smtp-auth-1, label[for="smtp-auth-"]').parent().parent().show(),e("label[for='smtp-password']").html(wysija_translations.password),a()),e("#restapipossible").hide(),e("#smtp-host").val()){case"smtp.gmail.com":""==y&&(e("#smtp-port").val("465"),e("#smtp-secure").val("ssl"),e("#smtp-login").val("your_username@gmail.com"));break;case"smtp.sendgrid.net":e("#restapipossible").show();break;case"mailpoet.com":e('#smtp-port, #smtp-secure, #smtp-login, label[for="smtp-auth-"]').parent().parent().hide(),e("label[for='smtp-password']").html(wysija_translations.api);break;case"sparkpost.com":e('#smtp-port, #smtp-secure, #smtp-login, label[for="smtp-auth-"]').parent().parent().hide(),e("label[for='smtp-password']").html(wysija_translations.api);break;case"":""==y&&(e("#smtp-port").val("25"),e("#smtp-secure").val("0"),e("#smtp-login").val(""))}""==y&&e("#smtp-secure").change()}function a(){"smtp"==e('input[name="wysija[config][sending_method]"]:checked').val()&&("none"!=e("#restapipossible").css("display")&&e("#smtp-rest").attr("checked")?e(".choice-no-restapi").hide():e(".choice-no-restapi").show())}function s(){1===parseInt(e('input[name="wysija[config][confirm_dbleoptin]"]:checked').attr("value"))?e(".confirmemail").fadeIn():e(".confirmemail").fadeOut()}function o(){var i=e(".mailpoet-frequency_warning"),n=e("#sending-emails-each"),t=["one_min","two_min","five_min","ten_min"];-1!==e.inArray(n.val(),t)?i.removeClass("hidden"):i.addClass("hidden")}function c(){return"gmail"==e('input[name="wysija[config][sending_method]"]:checked').val()}function r(){c()?e('select[name="wysija[config][sending_emails_each]"] option[value="hourly"]').length>0&&(e("#sending-emails-number").val("20"),e('select[name="wysija[config][sending_emails_each]"]').val("hourly"),e("#sending-emails-number").attr("readonly","readonly"),e('select[name="wysija[config][sending_emails_each]"]').attr("disabled","disabled")):(e('select[name="wysija[config][sending_emails_each]"]').removeAttr("disabled"),e("#sending-emails-number").removeAttr("readonly"))}function l(){return wysijaAJAX.task="bounce_connect",wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.bounceconnect,wysijaAJAX.dataType="json",wysijaAJAXcallback.onSuccess=function(i){var n="";return i.result.result&&(n='<a class="bounce-submit button-secondary" href2="admin.php?page=wysija_campaigns&action=test_bounce">'+wysijatrans.processbounce+"</a>"),displaychange?e(".allmsgs.ui-dialog-content.ui-widget-content").append(n):e("#bounce-connector").after(n),!0},e.WYSIJA_SEND(),!1}function d(){return wysijaAJAX.task="bounce_process",wysijaAJAX._wpnonce=wysijanonces.config.bounce_process,wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.processbounceT,wysijaAJAX.dataType="html",e(".allmsgs").dialog(),e.WYSIJA_SEND(),!1}function m(){"undefined"!=typeof this?e.each(e(".activateInput"),function(){h(this)}):h(this)}function h(i){e(i).attr("checked")?e("#"+e(i).attr("id")+"_linkname").fadeIn():e("#"+e(i).attr("id")+"_linkname").fadeOut()}function u(){subscribersCountList=[],e(".subscribers-count-list").each(function(){e(this).is(":checked")&&subscribersCountList.push(e(this).val())}),shortCode="[",shortCode+="wysija_subscribers_count",subscribersCountList.length>0&&(shortCode+=' list_id="'+subscribersCountList.join()+'" '),shortCode+="]",e(".subscribers-count-shortcode").val(shortCode)}function p(){switch(e("#ms-restapipossible").hide(),e("#ms-smtp-host").val()){case"smtp.gmail.com":""==_&&(e("#ms-smtp-port").val("465"),e("#ms-smtp-secure").val("ssl"),e("#ms-smtp-login").val("your_username@gmail.com"));break;case"smtp.sendgrid.net":e("#ms-restapipossible").show();break;case"":""==_&&(e("#ms-smtp-port").val("25"),e("#ms-smtp-secure").val("0"),e("#ms-smtp-login").val(""))}""==_&&e("#ms-smtp-secure").change()}function g(){"smtp"==e('input[name="wysija[config][ms_sending_method]"]:checked').val()&&("none"!=e("#ms-restapipossible").css("display")&&e("#ms-smtp-rest").attr("checked")?e(".ms-choice-no-restapi").hide():e(".ms-choice-no-restapi").show())}function f(){-1!==e.inArray(e("#ms-sending-emails-each").val(),["one_min","two_min","five_min","ten_min"])?e(".ms-choice-under15").show():e(".ms-choice-under15").hide()}function w(){"one-for-all"==e('input[name="wysija[config][ms_sending_config]"]:checked').val()?e(".choice-one-for-all").show():e(".choice-one-for-all").hide()}var y=e("#smtp-login").val();e(".hidechoice").hide(),e(".choice-sending-method-"+e('input[name="wysija[config][sending_method]"]:checked').val()).show(),e('input[name="wysija[config][sending_method]"]').change(function(){e(".hidechoice").hide(),e(".choice-sending-method-"+this.value).show(),r()}),e("#sending-emails-each").change(function(){o()}),e("#linksendingmethod").click(function(){e("#tabs").tabs("select",e(this).attr("href"))}),e("#mainmenu li a").click(function(){e("#redirecttab").val(e(this).attr("href"))}),e('input[name="wysija[config][confirm_dbleoptin]"]').change(s),e("#confirm_dbleoptin-1").click(function(){return confirm(wysijatrans.doubleoptinon)}),e("#confirm_dbleoptin-0").click(function(){return confirm(wysijatrans.doubleoptinoff)}),e('input[name="wysija[config][sending_emails_site_method]"]').change(function(){"sendmail"==e('input[name="wysija[config][sending_emails_site_method]"]:checked').val()?e("#p-sending-emails-site-method-sendmail-path").show():e("#p-sending-emails-site-method-sendmail-path").hide()}),e('input[name="wysija[config][sending_emails_site_method]"]').change(),e(".page_select").change(function(){n(this)}),e("#manage_subscriptions").change(function(){i()}),e("#smtp-host").keyup(t),e("#smtp-rest").change(a),e("#button-regenerate-dkim").click(function(){return e("#sending-emails-site-method-phpmail").attr("checked","checked"),e("#dkim_regenerate").val("regenerate"),e("#wysija-settings").submit(),!1}),e("#bounce-connector").click(l),e(document).on("click",".bounce-submit",function(){return d(),e(".allmsgs").dialog("close"),tb_show(wysijatrans.processbounceT,e(this).attr("href2")+"&KeepThis=true&TB_iframe=true&height=400&width=600",null),tb_showIframe(),!1}),e(".forwardto").change(function(){e(this).attr("checked")?e("#"+e(this).attr("id")+"_input").show():e("#"+e(this).attr("id")+"_input").hide()}),e.each(e(".hideifnovalue"),function(){""==e(this).find("input").val()&&e(this).hide()}),e("#wysija-settings").submit(function(){var i=!1;return e(".bounce-forward-email").each(function(){var n=trim(e(this).val());""!==n&&n==e("#bounce_email").val()&&(e('#wysija-tabs a[href="#bounce"]').trigger("click"),e('#wysija-innertabs a[href="#actions"]').trigger("click"),e(this).css("border","1px solid #CC0000"),e("#bounce-msg-error").addClass("error"),e("#bounce-msg-error").html(wysijatrans.errorbounceforward),i=!0)}),i?!1:void e('select[name="wysija[config][sending_emails_each]"]').removeAttr("disabled")}),e("#bounce-process-auto").attr("checked")?e("#bounce-frequency").show():e("#bounce-frequency").hide(),e("#bounce-process-auto").change(function(){e(this).attr("checked")?e("#bounce-frequency").show():e("#bounce-frequency").hide()}),e(".activateInput").change(m),e(document).on("click","#wysija-innertabs .nav-tab",function(i,n){var t,a=e(".wysija-innerpanel"),s=e("#wysija-innertabs").children(".nav-tab"),o=e(this),c=o.attr("href").replace("#",""),r={};return"undefined"==typeof n&&(n=!0),a.each(function(i,n){var t=e(n);r[t.attr("id")]=t}),t=r[c],s.removeClass("nav-tab-active"),o.addClass("nav-tab-active"),a.not(".hidden").addClass("hidden"),t.removeClass("hidden"),n&&(window.location.hash="inner-tab-"+c),t.trigger("shown.innertab.mailpoet"),!1}),e(document).on("click","#wysija-tabs .nav-tab",function(i,n){var t,a=e(".wysija-panel"),s=e("#wysija-tabs").children(".nav-tab"),o=e(this),c=o.attr("href").replace("#",""),r={};return"undefined"==typeof n&&(n=!0),a.each(function(i,n){var t=e(n);r[t.attr("id")]=t}),t=r[c],s.removeClass("nav-tab-active"),o.addClass("nav-tab-active"),a.not(".hidden").addClass("hidden"),t.removeClass("hidden"),n&&(window.location.hash="tab-"+c),t.trigger("shown.tab.mailpoet"),!1}),e(document).on("click","#tip-send-with",function(i){e('.nav-tab[href="#sendingmethod"]').trigger("click"),i.preventDefault()}),e(window).load(function(){if(window.location.hash.length>0){var i=window.location.hash.replace("tab-","");e('#wysija-tabs .nav-tab[href="'+i+'"]').trigger("click")}else e("#wysija-tabs .nav-tab").first().trigger("click",!1);if(1===window.location.hash.indexOf("inner-tab")){var n=e('#wysija-innertabs .nav-tab[href="'+window.location.hash.replace("inner-tab-","")+'"]').trigger("click");e('#wysija-tabs .nav-tab[href="#'+n.parents(".wysija-panel").attr("id")+'"]').trigger("click",!1)}else e("#wysija-innertabs .nav-tab-active").trigger("click",!1)}),e(document).ready(function(){r(),o(),s(),m(),t(),a(),n(null),i(),e(".subscribers-count-list").change(u),e("#analytics-0").is(":checked")&&e("#advanced .industry").hide(),e("#analytics-1").change(function(){"1"==e(this).val()&&e("#advanced .industry").show()}),e("#analytics-0").change(function(){"0"==e(this).val()&&e("#advanced .industry").hide()}),e("#"+getURLParameter("scroll_to")).length>0&&(e("html,body").animate({scrollTop:e("#"+getURLParameter("scroll_to")).offset().top-e("#wpadminbar").height()},500),e("#"+getURLParameter("scroll_to")).css({"background-color":"#f8fcff","font-size":"16px","font-weight":"bold"}))}),e("#dkimpub, #domainrecord, .subscribers-count-shortcode").click(function(){this.select()});var _=e("#ms-smtp-login").val();e(".ms-hidechoice").hide(),e(".ms-choice-sending-method-"+e('input[name="wysija[config][ms_sending_method]"]:checked').val()).show(),e('input[name="wysija[config][ms_sending_method]"]').change(function(){e(".ms-hidechoice").hide(),e(".ms-choice-sending-method-"+this.value).show()}),e("#ms-sending-emails-each").change(function(){f()}),e('input[name="wysija[config][ms_sending_config]"]').change(function(){w()}),e('input[name="wysija[config][ms_sending_emails_site_method]"]').change(function(){"sendmail"==e('input[name="wysija[config][ms_sending_emails_site_method]"]:checked').val()?e("#ms_p-sending-emails-site-method-sendmail-path").show():e("#ms_p-sending-emails-site-method-sendmail-path").hide()}),e('input[name="wysija[config][ms_sending_emails_site_method]"]').change(),e("#ms-smtp-host").keyup(p),e("#ms-smtp-rest").change(g),e.each(e(".hideifnovalue"),function(){""===e(this).find("input").val()&&e(this).hide()}),e("table.capabilities_form .view_all").click(function(){e("table.capabilities_form tr.hidden").removeClass("hidden"),objTr=e(this).parents("tr")[0],e(objTr).remove()}),e(".mailpoet-test-delivery").on({click:function(i){i.preventDefault();var n="network"===e(".mailpoet-delivery-method:checked").val()||e(this).data("multisite");return n?(wysijaAJAX.task="send_test_mail_ms",wysijaAJAX._wpnonce=wysijanonces.config.send_test_mail_ms):(wysijaAJAX.task="send_test_mail",wysijaAJAX._wpnonce=wysijanonces.config.send_test_mail),wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.testemail,wysijaAJAX.dataType="json",e.WYSIJA_SEND(),!1}}),e(document).ready(function(){e("#smtp-host").keyup(),w(),f(),p(),g()})}),window.mailpoet="object"==typeof window.mailpoet?window.mailpoet:{$:{}},function(e,i){"use strict";var n=i.mailpoet,t=n.fn={};t.getSendingMethod=function(){return n.$.sending_method instanceof jQuery||(n.$.sending_method=e('input[name="wysija[config][sending_method]"]')),n.$.sending_method.filter(":checked").val()},t.isGoodFromAddress=function(e){var n=e.split("@")[1];return"undefined"==typeof n||""===n?!1:n.toLowerCase()!==i.location.host.toLowerCase()?!1:!0},t.isGmailAddress=function(e){var i=e.split("@")[1];return"undefined"==typeof i||""===i?!1:"gmail.com"!==i.toLowerCase()?!1:!0}}(jQuery,window),function(e,i){"use strict";var n=i.mailpoet;e(document).ready(function(){"object"==typeof e.fn.tooltip&&(n.$.from_email=e("#from_email"),n.$.from_email.tooltip({animation:!0,placement:"bottom",trigger:"manual",html:!0,title:function(){return n.$.from_email.data("message")}}).on({"verifyEmail.mailpoet":function(){if(n.fn.isGoodFromAddress(n.$.from_email.val()))return n.$.from_email.data("message","").tooltip("hide");if("gmail"===n.fn.getSendingMethod())return n.$.from_email.data("message","").tooltip("hide");var e="";return e=n.fn.isGmailAddress(n.$.from_email.val())?mpEmailCheck.gmailText:mpEmailCheck.text,n.$.from_email.is(":visible")?n.$.from_email.data("message",e).tooltip("show"):n.$.from_email.tooltip("hide")},keyup:function(){n.$.from_email.trigger("verifyEmail.mailpoet")}}).trigger("verifyEmail.mailpoet"),n.$.panels=e(".wysija-panel"),n.$.panels.filter("#basics").on({"shown.tab.mailpoet":function(){n.$.from_email.trigger("verifyEmail.mailpoet")}}))})}(jQuery,window),function(e,i){"use strict";var n=i.mailpoet;e(document).on({ready:function(){n.$.geeky=e(".mailpoet-geeky-toggle"),n.$.geeky.data("l18n",{hide:n.$.geeky.data("hide"),show:n.$.geeky.text()}),n.$.geeky_rows=e(".super-advanced"),n.$.geeky.on({click:function(i){i.preventDefault();var t=n.$.geeky.data("l18n");n.$.geeky.hasClass("is_toggled")?(n.$.geeky.removeClass("is_toggled").text(t.hide),n.$.geeky_rows.removeClass("hidden"),void 0!==i.originalEvent&&e.cookie("geeky_option",1)):(n.$.geeky.addClass("is_toggled").text(t.show),n.$.geeky_rows.addClass("hidden"),void 0!==i.originalEvent&&e.cookie("geeky_option",0))}}),1==e.cookie("geeky_option")?n.$.geeky.trigger("click"):n.$.geeky_rows.addClass("hidden")}})}(jQuery,window);
1
+ jQuery(function(e){function i(){e("#manage_subscriptions").attr("checked")?e(".manage_subscriptions").fadeIn():e(".manage_subscriptions").fadeOut()}function t(i){null===i?e.each(e(".page_select"),function(){e("#"+e(this).attr("id")+"-links-"+e(this).val()).fadeIn()}):(id_section="#"+e(i).attr("id")+"-links",e(id_section+" span").hide(),e(id_section+"-"+e(i).val()).fadeIn())}function n(){switch(e("#sending-method-smtp").attr("checked")&&(e('#smtp-port, #smtp-secure, #smtp-login, #smtp-auth-1, label[for="smtp-auth-"]').parent().parent().show(),e("label[for='smtp-password']").html(wysija_translations.password),a()),e("#restapipossible").hide(),e("#smtp-host").val()){case"smtp.gmail.com":""==y&&(e("#smtp-port").val("465"),e("#smtp-secure").val("ssl"),e("#smtp-login").val("your_username@gmail.com"));break;case"smtp.sendgrid.net":e("#sending-method-smtp").is(":checked")?e("#restapipossible").show():e("#restapipossible").hide();break;case"mailpoet.com":e('#smtp-port, #smtp-secure, #smtp-login, label[for="smtp-auth-"]').parent().parent().hide(),e("label[for='smtp-password']").html(wysija_translations.api);break;case"sparkpost.com":e('#smtp-port, #smtp-secure, #smtp-login, label[for="smtp-auth-"]').parent().parent().hide(),e("label[for='smtp-password']").html(wysija_translations.api);break;case"":""==y&&(e("#smtp-port").val("25"),e("#smtp-secure").val("0"),e("#smtp-login").val(""));break;default:e("#sending-method-smtp").is(":checked")&&e('#smtp-port, #smtp-secure, #smtp-login, #smtp-auth-1, label[for="smtp-auth-"]').parent().parent().show()}""==y&&e("#smtp-secure").change(),e("#smtp-rest").trigger("change")}function a(){"smtp"==e('input[name="wysija[config][sending_method]"]:checked').val()&&("none"!=e("#restapipossible").css("display")&&e("#smtp-rest").attr("checked")?(e('#smtp-port, #smtp-secure, #smtp-auth-1, label[for="smtp-auth-"]').parent().parent().hide(),e(".choice-no-restapi").hide()):(e('#smtp-port, #smtp-secure, #smtp-auth-1, label[for="smtp-auth-"]').parent().parent().show(),e(".choice-no-restapi").show()))}function s(){1===parseInt(e('input[name="wysija[config][confirm_dbleoptin]"]:checked').attr("value"))?e(".confirmemail").fadeIn():e(".confirmemail").fadeOut()}function o(){var i=e(".mailpoet-frequency_warning"),t=e("#sending-emails-each"),n=["one_min","two_min","five_min","ten_min"];-1!==e.inArray(t.val(),n)?i.removeClass("hidden"):i.addClass("hidden")}function c(){return"gmail"==e('input[name="wysija[config][sending_method]"]:checked').val()}function r(){c()?e('select[name="wysija[config][sending_emails_each]"] option[value="hourly"]').length>0&&(e("#sending-emails-number").val("20"),e('select[name="wysija[config][sending_emails_each]"]').val("hourly"),e("#sending-emails-number").attr("readonly","readonly"),e('select[name="wysija[config][sending_emails_each]"]').attr("disabled","disabled")):(e('select[name="wysija[config][sending_emails_each]"]').removeAttr("disabled"),e("#sending-emails-number").removeAttr("readonly"))}function l(){return wysijaAJAX.task="bounce_connect",wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.bounceconnect,wysijaAJAX.dataType="json",wysijaAJAXcallback.onSuccess=function(i){var t="";return i.result.result&&(t='<a class="bounce-submit button-secondary" href2="admin.php?page=wysija_campaigns&action=test_bounce">'+wysijatrans.processbounce+"</a>"),displaychange?e(".allmsgs.ui-dialog-content.ui-widget-content").append(t):e("#bounce-connector").after(t),!0},e.WYSIJA_SEND(),!1}function d(){return wysijaAJAX.task="bounce_process",wysijaAJAX._wpnonce=wysijanonces.config.bounce_process,wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.processbounceT,wysijaAJAX.dataType="html",e(".allmsgs").dialog(),e.WYSIJA_SEND(),!1}function m(){"undefined"!=typeof this?e.each(e(".activateInput"),function(){h(this)}):h(this)}function h(i){e(i).attr("checked")?e("#"+e(i).attr("id")+"_linkname").fadeIn():e("#"+e(i).attr("id")+"_linkname").fadeOut()}function u(){subscribersCountList=[],e(".subscribers-count-list").each(function(){e(this).is(":checked")&&subscribersCountList.push(e(this).val())}),shortCode="[",shortCode+="wysija_subscribers_count",subscribersCountList.length>0&&(shortCode+=' list_id="'+subscribersCountList.join()+'" '),shortCode+="]",e(".subscribers-count-shortcode").val(shortCode)}function p(){switch(e("#ms-restapipossible").hide(),e("#ms-smtp-host").val()){case"smtp.gmail.com":""==b&&(e("#ms-smtp-port").val("465"),e("#ms-smtp-secure").val("ssl"),e("#ms-smtp-login").val("your_username@gmail.com"));break;case"smtp.sendgrid.net":e("#ms-restapipossible").show();break;case"":""==b&&(e("#ms-smtp-port").val("25"),e("#ms-smtp-secure").val("0"),e("#ms-smtp-login").val(""))}""==b&&e("#ms-smtp-secure").change()}function g(){"smtp"==e('input[name="wysija[config][ms_sending_method]"]:checked').val()&&("none"!=e("#ms-restapipossible").css("display")&&e("#ms-smtp-rest").attr("checked")?e(".ms-choice-no-restapi").hide():e(".ms-choice-no-restapi").show())}function f(){-1!==e.inArray(e("#ms-sending-emails-each").val(),["one_min","two_min","five_min","ten_min"])?e(".ms-choice-under15").show():e(".ms-choice-under15").hide()}function w(){"one-for-all"==e('input[name="wysija[config][ms_sending_config]"]:checked').val()?e(".choice-one-for-all").show():e(".choice-one-for-all").hide()}var y=e("#smtp-login").val();e(".hidechoice").hide(),e(".choice-sending-method-"+e('input[name="wysija[config][sending_method]"]:checked').val()).show(),e('input[name="wysija[config][sending_method]"]').change(function(){e(".hidechoice").hide(),e(".choice-sending-method-"+this.value).show(),r()}),e("#sending-emails-each").change(function(){o()}),e("#linksendingmethod").click(function(){e("#tabs").tabs("select",e(this).attr("href"))}),e("#mainmenu li a").click(function(){e("#redirecttab").val(e(this).attr("href"))}),e('input[name="wysija[config][confirm_dbleoptin]"]').change(s),e("#confirm_dbleoptin-1").click(function(){return confirm(wysijatrans.doubleoptinon)}),e("#confirm_dbleoptin-0").click(function(){return confirm(wysijatrans.doubleoptinoff)}),e('input[name="wysija[config][sending_emails_site_method]"]').change(function(){"sendmail"==e('input[name="wysija[config][sending_emails_site_method]"]:checked').val()?e("#p-sending-emails-site-method-sendmail-path").show():e("#p-sending-emails-site-method-sendmail-path").hide()}),e('input[name="wysija[config][sending_emails_site_method]"]').change(),e(".page_select").change(function(){t(this)}),e("#manage_subscriptions").change(function(){i()}),e("#smtp-host").keyup(n),e("input.mailpoet-delivery-method").on("change",n),e("#smtp-rest").on("change",a),e("#button-regenerate-dkim").click(function(){return e("#sending-emails-site-method-phpmail").attr("checked","checked"),e("#dkim_regenerate").val("regenerate"),e("#wysija-settings").submit(),!1}),e("#bounce-connector").click(l),e(document).on("click",".bounce-submit",function(){return d(),e(".allmsgs").dialog("close"),tb_show(wysijatrans.processbounceT,e(this).attr("href2")+"&KeepThis=true&TB_iframe=true&height=400&width=600",null),tb_showIframe(),!1}),e(".forwardto").change(function(){e(this).attr("checked")?e("#"+e(this).attr("id")+"_input").show():e("#"+e(this).attr("id")+"_input").hide()}),e.each(e(".hideifnovalue"),function(){""==e(this).find("input").val()&&e(this).hide()}),e("#wysija-settings").submit(function(){var i=!1;return e(".bounce-forward-email").each(function(){var t=trim(e(this).val());""!==t&&t==e("#bounce_email").val()&&(e('#wysija-tabs a[href="#bounce"]').trigger("click"),e('#wysija-innertabs a[href="#actions"]').trigger("click"),e(this).css("border","1px solid #CC0000"),e("#bounce-msg-error").addClass("error"),e("#bounce-msg-error").html(wysijatrans.errorbounceforward),i=!0)}),i?!1:void e('select[name="wysija[config][sending_emails_each]"]').removeAttr("disabled")}),e("#bounce-process-auto").attr("checked")?e("#bounce-frequency").show():e("#bounce-frequency").hide(),e("#bounce-process-auto").change(function(){e(this).attr("checked")?e("#bounce-frequency").show():e("#bounce-frequency").hide()}),e(".activateInput").change(m),e(document).on("click","#wysija-innertabs .nav-tab",function(i,t){var n,a=e(".wysija-innerpanel"),s=e("#wysija-innertabs").children(".nav-tab"),o=e(this),c=o.attr("href").replace("#",""),r={};return"undefined"==typeof t&&(t=!0),a.each(function(i,t){var n=e(t);r[n.attr("id")]=n}),n=r[c],s.removeClass("nav-tab-active"),o.addClass("nav-tab-active"),a.not(".hidden").addClass("hidden"),n.removeClass("hidden"),t&&(window.location.hash="inner-tab-"+c),n.trigger("shown.innertab.mailpoet"),!1}),e(document).on("click","#wysija-tabs .nav-tab",function(i,t){var n,a=e(".wysija-panel"),s=e("#wysija-tabs").children(".nav-tab"),o=e(this),c=o.attr("href").replace("#",""),r={};return"undefined"==typeof t&&(t=!0),a.each(function(i,t){var n=e(t);r[n.attr("id")]=n}),n=r[c],s.removeClass("nav-tab-active"),o.addClass("nav-tab-active"),a.not(".hidden").addClass("hidden"),n.removeClass("hidden"),t&&(window.location.hash="tab-"+c),n.trigger("shown.tab.mailpoet"),!1}),e(document).on("click","#tip-send-with",function(i){e('.nav-tab[href="#sendingmethod"]').trigger("click"),i.preventDefault()}),e(window).load(function(){if(window.location.hash.length>0){var i=window.location.hash.replace("tab-","");e('#wysija-tabs .nav-tab[href="'+i+'"]').trigger("click")}else e("#wysija-tabs .nav-tab").first().trigger("click",!1);if(1===window.location.hash.indexOf("inner-tab")){var t=e('#wysija-innertabs .nav-tab[href="'+window.location.hash.replace("inner-tab-","")+'"]').trigger("click");e('#wysija-tabs .nav-tab[href="#'+t.parents(".wysija-panel").attr("id")+'"]').trigger("click",!1)}else e("#wysija-innertabs .nav-tab-active").trigger("click",!1)}),e(document).ready(function(){r(),o(),s(),m(),n(),a(),t(null),i(),e(".subscribers-count-list").change(u),e("#analytics-0").is(":checked")&&e("#advanced .industry").hide(),e("#analytics-1").change(function(){"1"==e(this).val()&&e("#advanced .industry").show()}),e("#analytics-0").change(function(){"0"==e(this).val()&&e("#advanced .industry").hide()}),e("#"+getURLParameter("scroll_to")).length>0&&(e("html,body").animate({scrollTop:e("#"+getURLParameter("scroll_to")).offset().top-e("#wpadminbar").height()},500),e("#"+getURLParameter("scroll_to")).css({"background-color":"#f8fcff","font-size":"16px","font-weight":"bold"}))}),e("#dkimpub, #domainrecord, .subscribers-count-shortcode").click(function(){this.select()});var b=e("#ms-smtp-login").val();e(".ms-hidechoice").hide(),e(".ms-choice-sending-method-"+e('input[name="wysija[config][ms_sending_method]"]:checked').val()).show(),e('input[name="wysija[config][ms_sending_method]"]').change(function(){e(".ms-hidechoice").hide(),e(".ms-choice-sending-method-"+this.value).show()}),e("#ms-sending-emails-each").change(function(){f()}),e('input[name="wysija[config][ms_sending_config]"]').change(function(){w()}),e('input[name="wysija[config][ms_sending_emails_site_method]"]').change(function(){"sendmail"==e('input[name="wysija[config][ms_sending_emails_site_method]"]:checked').val()?e("#ms_p-sending-emails-site-method-sendmail-path").show():e("#ms_p-sending-emails-site-method-sendmail-path").hide()}),e('input[name="wysija[config][ms_sending_emails_site_method]"]').change(),e("#ms-smtp-host").keyup(p),e("input.mailpoet-delivery-method").on("change",p),e("#ms-smtp-rest").change(g),e.each(e(".hideifnovalue"),function(){""===e(this).find("input").val()&&e(this).hide()}),e("table.capabilities_form .view_all").click(function(){e("table.capabilities_form tr.hidden").removeClass("hidden"),objTr=e(this).parents("tr")[0],e(objTr).remove()}),e(".mailpoet-test-delivery").on({click:function(i){i.preventDefault();var t="network"===e(".mailpoet-delivery-method:checked").val()||e(this).data("multisite");return t?(wysijaAJAX.task="send_test_mail_ms",wysijaAJAX._wpnonce=wysijanonces.config.send_test_mail_ms):(wysijaAJAX.task="send_test_mail",wysijaAJAX._wpnonce=wysijanonces.config.send_test_mail),wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.testemail,wysijaAJAX.dataType="json",e.WYSIJA_SEND(),!1}}),e(document).ready(function(){e("#smtp-host").keyup(),w(),f(),p(),g()})}),window.mailpoet="object"==typeof window.mailpoet?window.mailpoet:{$:{}},function(e,i){"use strict";var t=i.mailpoet,n=t.fn={};n.getSendingMethod=function(){return t.$.sending_method instanceof jQuery||(t.$.sending_method=e('input[name="wysija[config][sending_method]"]')),t.$.sending_method.filter(":checked").val()},n.isGoodFromAddress=function(e){var t=e.split("@")[1];return"undefined"==typeof t||""===t?!1:t.toLowerCase()!==i.location.host.toLowerCase()?!1:!0},n.isGmailAddress=function(e){var i=e.split("@")[1];return"undefined"==typeof i||""===i?!1:"gmail.com"!==i.toLowerCase()?!1:!0}}(jQuery,window),function(e,i){"use strict";var t=i.mailpoet;e(document).ready(function(){"object"==typeof e.fn.tooltip&&(t.$.from_email=e("#from_email"),t.$.from_email.tooltip({animation:!0,placement:"bottom",trigger:"manual",html:!0,title:function(){return t.$.from_email.data("message")}}).on({"verifyEmail.mailpoet":function(){if(t.fn.isGoodFromAddress(t.$.from_email.val()))return t.$.from_email.data("message","").tooltip("hide");if("gmail"===t.fn.getSendingMethod())return t.$.from_email.data("message","").tooltip("hide");var e="";return e=t.fn.isGmailAddress(t.$.from_email.val())?mpEmailCheck.gmailText:mpEmailCheck.text,t.$.from_email.is(":visible")?t.$.from_email.data("message",e).tooltip("show"):t.$.from_email.tooltip("hide")},keyup:function(){t.$.from_email.trigger("verifyEmail.mailpoet")}}).trigger("verifyEmail.mailpoet"),t.$.panels=e(".wysija-panel"),t.$.panels.filter("#basics").on({"shown.tab.mailpoet":function(){t.$.from_email.trigger("verifyEmail.mailpoet")}}))})}(jQuery,window),function(e,i){"use strict";var t=i.mailpoet;e(document).on({ready:function(){t.$.geeky=e(".mailpoet-geeky-toggle"),t.$.geeky.data("l18n",{hide:t.$.geeky.data("hide"),show:t.$.geeky.text()}),t.$.geeky_rows=e(".super-advanced"),t.$.geeky.on({click:function(i){i.preventDefault();var n=t.$.geeky.data("l18n");t.$.geeky.hasClass("is_toggled")?(t.$.geeky.removeClass("is_toggled").text(n.hide),t.$.geeky_rows.removeClass("hidden"),void 0!==i.originalEvent&&e.cookie("geeky_option",1)):(t.$.geeky.addClass("is_toggled").text(n.show),t.$.geeky_rows.addClass("hidden"),void 0!==i.originalEvent&&e.cookie("geeky_option",0))}}),1==e.cookie("geeky_option")?t.$.geeky.trigger("click"):t.$.geeky_rows.addClass("hidden")}})}(jQuery,window);
languages/wysija-newsletters-de.mo ADDED
Binary file
languages/wysija-newsletters-de_DE.mo CHANGED
Binary file
languages/wysija-newsletters-en_GB.mo CHANGED
Binary file
languages/wysija-newsletters-es_ES.mo CHANGED
Binary file
languages/wysija-newsletters-fr_FR.mo CHANGED
Binary file
languages/wysija-newsletters-id_ID.mo ADDED
Binary file
languages/wysija-newsletters-it_IT.mo CHANGED
Binary file
languages/wysija-newsletters-nl_NL.mo CHANGED
Binary file
languages/wysija-newsletters-nn_NO.mo ADDED
Binary file
languages/wysija-newsletters-pt_BR.mo CHANGED
Binary file
languages/wysija-newsletters-pt_PT.mo CHANGED
Binary file
languages/wysija-newsletters-ru_RU.mo CHANGED
Binary file
languages/wysija-newsletters-sq.mo CHANGED
Binary file
languages/wysija-newsletters-sv_SE.mo CHANGED
Binary file
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: wysija
3
  Tags: newsletter, newsletters, email newsletter, email subscription, newsletter signup, post notification, autoresponder, newsletter alert, auto newsletter, automatic post notification, email newsletters, email signup, auto post notifications, newsletter widget, newsletter builder, subscribe widget, signup widget, email subscription, newsletter plugin, widget, subscription, emailing, mailpoet, wysija, mandrill, sendgrid
4
  Requires at least: 3.5
5
- Tested up to: 4.7.1
6
- Stable tag: 2.7.6
7
  Send newsletters post notifications or autoresponders from WordPress easily, and beautifully. Start to capture subscribers with our widget now.
8
 
9
  == Description ==
@@ -132,6 +132,17 @@ Our [support site](http://support.mailpoet.com/) has plenty of articles and a ti
132
 
133
  == Changelog ==
134
 
 
 
 
 
 
 
 
 
 
 
 
135
  = 2.7.6 - 2017-01-18 =
136
  * Fixed post categories not being displayed in sent newsletters
137
  * Fixed PHPMailer vulnerability
2
  Contributors: wysija
3
  Tags: newsletter, newsletters, email newsletter, email subscription, newsletter signup, post notification, autoresponder, newsletter alert, auto newsletter, automatic post notification, email newsletters, email signup, auto post notifications, newsletter widget, newsletter builder, subscribe widget, signup widget, email subscription, newsletter plugin, widget, subscription, emailing, mailpoet, wysija, mandrill, sendgrid
4
  Requires at least: 3.5
5
+ Tested up to: 4.7.2
6
+ Stable tag: 2.7.8
7
  Send newsletters post notifications or autoresponders from WordPress easily, and beautifully. Start to capture subscribers with our widget now.
8
 
9
  == Description ==
132
 
133
  == Changelog ==
134
 
135
+ = 2.7.8 - 2017-03-03 =
136
+ * Fixed sending issues when MailPoet's sending service is selected
137
+ * Fixed sending post notifications when tag filters are used
138
+ * Fixed the display of incorrect newsletter title in browser preview
139
+ * Fixed PHP notices associated with sending on multisite hosts
140
+ * Fixed broken DKIM signing
141
+
142
+ = 2.7.7 - 2017-01-31 =
143
+ * Fixed activation issues on PHP 5.2
144
+ * Removed PHPMailer library in compliance with the new WordPress security policy. Please report any sending issues!
145
+
146
  = 2.7.6 - 2017-01-18 =
147
  * Fixed post categories not being displayed in sent newsletters
148
  * Fixed PHPMailer vulnerability
views/back/campaigns.php CHANGED
@@ -2928,7 +2928,7 @@ class WYSIJA_view_back_campaigns extends WYSIJA_view_back {
2928
  }
2929
 
2930
  $sharing_data = $model_config->getValue('analytics');
2931
- if( empty( $sharing_data ) ){
2932
  $data['sections'][] = array(
2933
  'title' => __('One quick question...',WYSIJA),
2934
 
@@ -2950,7 +2950,7 @@ class WYSIJA_view_back_campaigns extends WYSIJA_view_back {
2950
  <div style="clear:both;"></div>',
2951
  'format' => 'title-content',
2952
  );
2953
- }
2954
 
2955
 
2956
 
@@ -2972,14 +2972,14 @@ class WYSIJA_view_back_campaigns extends WYSIJA_view_back {
2972
  );
2973
  }
2974
 
2975
- if( $show_survey ){
2976
  $data['sections'][] = array(
2977
  'title' => 'Answer our survey and make your plugin better',
2978
 
2979
  'content' => '<iframe frameborder="0" width="100%" height="600" scrolling="auto" allowtransparency="true" src="//mailpoet.polldaddy.com/s/what-s-new-sept-2015?iframe=1"><a href="//mailpoet.polldaddy.com/s/what-s-new-sept-2015">View Survey</a></iframe><hr/>',
2980
  'format' => 'title-content',
2981
  );
2982
- }
2983
 
2984
  if (isset($helper_readme->changelog[WYSIJA::get_version()])) {
2985
  $data['sections'][] = array(
2928
  }
2929
 
2930
  $sharing_data = $model_config->getValue('analytics');
2931
+ /* if( empty( $sharing_data ) ){
2932
  $data['sections'][] = array(
2933
  'title' => __('One quick question...',WYSIJA),
2934
 
2950
  <div style="clear:both;"></div>',
2951
  'format' => 'title-content',
2952
  );
2953
+ }*/
2954
 
2955
 
2956
 
2972
  );
2973
  }
2974
 
2975
+ /* if( $show_survey ){
2976
  $data['sections'][] = array(
2977
  'title' => 'Answer our survey and make your plugin better',
2978
 
2979
  'content' => '<iframe frameborder="0" width="100%" height="600" scrolling="auto" allowtransparency="true" src="//mailpoet.polldaddy.com/s/what-s-new-sept-2015?iframe=1"><a href="//mailpoet.polldaddy.com/s/what-s-new-sept-2015">View Survey</a></iframe><hr/>',
2980
  'format' => 'title-content',
2981
  );
2982
+ }*/
2983
 
2984
  if (isset($helper_readme->changelog[WYSIJA::get_version()])) {
2985
  $data['sections'][] = array(