Move mailer configuration to init method

[MAILPOET-2146]
This commit is contained in:
Pavel Dohnal
2019-07-24 10:40:00 +02:00
committed by M. Shull
parent d6f263ef3f
commit 8739646a6a
7 changed files with 40 additions and 23 deletions

View File

@ -36,7 +36,8 @@ class Mailer extends APIEndpoint {
function send($data = []) {
try {
$mailer = new \MailPoet\Mailer\Mailer(
$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

View File

@ -442,11 +442,7 @@ class Newsletters extends APIEndpoint {
try {
$mailer = (!empty($data['mailer'])) ?
$data['mailer'] :
new \MailPoet\Mailer\Mailer(
$mailer = false,
$sender = false,
$reply_to = false
);
new \MailPoet\Mailer\Mailer();
$extra_params = ['unsubscribe_url' => WPFunctions::get()->homeUrl()];
$result = $mailer->send($rendered_newsletter, $data['subscriber'], $extra_params);

View File

@ -36,7 +36,8 @@ class SendingQueue extends APIEndpoint {
// check that the sending method has been configured properly
try {
new \MailPoet\Mailer\Mailer(false);
$mailer = new \MailPoet\Mailer\Mailer();
$mailer->init();
} catch (\Exception $e) {
return $this->errorResponse([
$e->getCode() => $e->getMessage(),