Files
piratepoet/lib/API/JSON/v1/Mailer.php
Rostislav Wolny f5c9d0f7db Remove unnecessary test_email extra parameter for mailer->send
It was used only to prevent appending unprocessed subscribers into error message.
Since the message is now composed by on demand by MailerError the parameter is not needed any more.

[MAILPOET-1154]
2018-09-13 11:12:38 +02:00

47 lines
1.2 KiB
PHP

<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Config\AccessControl;
use MailPoet\Mailer\MailerLog;
if(!defined('ABSPATH')) exit;
class Mailer extends APIEndpoint {
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_EMAILS
);
function send($data = array()) {
try {
$mailer = new \MailPoet\Mailer\Mailer(
(isset($data['mailer'])) ? $data['mailer'] : false,
(isset($data['sender'])) ? $data['sender'] : false,
(isset($data['reply_to'])) ? $data['reply_to'] : false
);
$result = $mailer->send($data['newsletter'], $data['subscriber']);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
if($result['response'] === false) {
$error = sprintf(
__('The email could not be sent: %s', 'mailpoet'),
$result['error']->getMessage()
);
return $this->errorResponse(array(APIError::BAD_REQUEST => $error));
} else {
return $this->successResponse(null);
}
}
function resumeSending() {
MailerLog::resumeSending();
return $this->successResponse(null);
}
}