[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.118.20.140: ~ $
<?php

namespace MailPoet\API\JSON\v1;

if (!defined('ABSPATH')) exit;


use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\AccessControl;
use MailPoet\Mailer\MailerLog;
use MailPoet\Mailer\MetaInfo;
use MailPoet\Services\AuthorizedEmailsController;
use MailPoet\Services\Bridge;
use MailPoet\Settings\SettingsController;
use MailPoet\WP\Functions as WPFunctions;

class Mailer extends APIEndpoint {

  /** @var AuthorizedEmailsController */
  private $authorizedEmailsController;

  /** @var Bridge */
  private $bridge;

  /** @var SettingsController */
  private $settings;

  /** @var MetaInfo */
  private $mailerMetaInfo;

  public $permissions = [
    'global' => AccessControl::PERMISSION_MANAGE_EMAILS,
  ];

  public function __construct(
    AuthorizedEmailsController $authorizedEmailsController,
    SettingsController $settings,
    Bridge $bridge,
    MetaInfo $mailerMetaInfo
  ) {
    $this->authorizedEmailsController = $authorizedEmailsController;
    $this->settings = $settings;
    $this->bridge = $bridge;
    $this->mailerMetaInfo = $mailerMetaInfo;
  }

  public function send($data = []) {
    try {
      $mailer = new \MailPoet\Mailer\Mailer();
      $mailer->init(
        (isset($data['mailer'])) ? $data['mailer'] : false,
        (isset($data['sender'])) ? $data['sender'] : false,
        (isset($data['reply_to'])) ? $data['reply_to'] : false
      );
      // report this as 'sending_test' in metadata since this endpoint is only used to test sending methods for now
      $extraParams = [
        'meta' => $this->mailerMetaInfo->getSendingTestMetaInfo(),
      ];
      $result = $mailer->send($data['newsletter'], $data['subscriber'], $extraParams);
    } catch (\Exception $e) {
      return $this->errorResponse([
        $e->getCode() => $e->getMessage(),
      ]);
    }

    if ($result['response'] === false) {
      $error = sprintf(
        WPFunctions::get()->__('The email could not be sent: %s', 'mailpoet'),
        $result['error']->getMessage()
      );
      return $this->errorResponse([APIError::BAD_REQUEST => $error]);
    } else {
      return $this->successResponse(null);
    }
  }

  public function resumeSending() {
    if ($this->settings->get(AuthorizedEmailsController::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING)) {
      $this->authorizedEmailsController->checkAuthorizedEmailAddresses();
    }
    MailerLog::resumeSending();
    return $this->successResponse(null);
  }

  public function getAuthorizedEmailAddresses() {
    $authorizedEmails = $this->bridge->getAuthorizedEmailAddresses();
    return $this->successResponse($authorizedEmails);
  }
}

Filemanager

Name Type Size Permission Actions
Analytics.php File 574 B 0644
AutomatedLatestContent.php File 2.67 KB 0644
AutomaticEmails.php File 2.67 KB 0644
CustomFields.php File 2.74 KB 0644
DynamicSegments.php File 10.45 KB 0644
FeatureFlags.php File 1.32 KB 0644
Forms.php File 10.67 KB 0644
ImportExport.php File 5.13 KB 0644
MP2Migrator.php File 1.53 KB 0644
Mailer.php File 2.61 KB 0644
NewsletterLinks.php File 940 B 0644
NewsletterTemplates.php File 3.14 KB 0644
Newsletters.php File 14.76 KB 0644
Premium.php File 2.16 KB 0644
Segments.php File 11.08 KB 0644
SendingQueue.php File 5.45 KB 0644
SendingTaskSubscribers.php File 3.51 KB 0644
Services.php File 8.72 KB 0644
Settings.php File 9.66 KB 0644
Setup.php File 920 B 0644
SubscriberStats.php File 2.22 KB 0644
Subscribers.php File 10.02 KB 0644
UserFlags.php File 994 B 0644
WoocommerceSettings.php File 776 B 0644
index.php File 0 B 0644