function getConnectMailPoetButton(): string { $subscribersCount = $this->subscribersFeature->getSubscribersCount(); $buttonLink = "https://account.mailpoet.com/?s={$subscribersCount}&utm_source=mailpoet&utm_medium=plugin&utm_campaign=disabled_mail_function"; $link = $this->wp->escAttr($buttonLink); return '

' . __('Connect MailPoet', 'mailpoet') . '

'; } /* * Test Mail Function Is Correctly Configured * * This is a workaround for detecting the user PHP mail() function is Correctly Configured and not disabled by the host */ private function testMailFunctionIsCorrectlyConfigured(): bool { if ($this->settings->get(DisabledMailFunctionNotice::DISABLED_MAIL_FUNCTION_CHECK, false)) { return false; // skip sending mail again } $replyToAddress = $this->settings->get('reply_to.address'); $senderAddress = $this->settings->get('sender.address'); $mailBody = "Hi there! \n Your website ([site:homepage_link]) sent you this email to confirm that it can send emails. If you're reading this email, then it works! You can now continue sending marketing emails with MailPoet! \n MailPoet on [site:homepage_link]"; $body = Shortcodes::process($mailBody, null, null, null, null); $sendTestMailData = [ 'mailer' => $this->settings->get('mta'), 'newsletter' => [ 'subject' => 'MailPoet can deliver your marketing emails!', 'body' => [ 'html' => nl2br($body), 'text' => $body, ], ], 'subscriber' => empty($replyToAddress) ? $senderAddress : $replyToAddress, ]; $sendMailResult = $this->sendTestMail($sendTestMailData); if (!$sendMailResult) { // Error with PHP mail() function // keep displaying notice $this->settings->set(DisabledMailFunctionNotice::DISABLED_MAIL_FUNCTION_CHECK, true); } return $sendMailResult; } /* * Send Test Mail * used to check for valid PHP mail() * * returns true if valid and okay * else returns false if invalid. * * We determine the mail function is invalid by checking against the Exception error thrown by PHPMailer * error message: Could not instantiate mail function. * * if the error is not equal to error message, we consider it okay. */ public function sendTestMail($data = []): bool { try { $mailer = $this->mailerFactory->buildMailer( $data['mailer'] ?? null, $data['sender'] ?? null, $data['reply_to'] ?? null ); // report this as 'sending_test' in metadata since this endpoint is only used to test sending methods for now $extraParams = [ 'meta' => [ 'email_type' => 'sending_test', 'subscriber_status' => 'unknown', 'subscriber_source' => 'administrator', ], ]; $result = $mailer->send($data['newsletter'], $data['subscriber'], $extraParams); if ($result['response'] === false) { $errorMessage = $result['error']->getMessage(); return !$this->checkForErrorMessage($errorMessage); } } catch (\Exception $e) { $errorMessage = $e->getMessage(); return !$this->checkForErrorMessage($errorMessage); } return true; } private function checkForErrorMessage($errorMessage): bool { $phpmailerError = 'Could not instantiate mail function'; $substringIndex = stripos($errorMessage, $phpmailerError); return $substringIndex !== false; } }
Fatal error: Uncaught Error: Class "MailPoet\Util\Notices\DisabledMailFunctionNotice" not found in /htdocs/wp-content/plugins/mailpoet/lib/Util/Notices/PermanentNotices.php:91 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2640): MailPoet\Util\Notices\PermanentNotices->__construct(Object(MailPoet\WP\Functions), Object(MailPoet\Settings\TrackingConfig), Object(MailPoet\Subscribers\SubscribersRepository), Object(MailPoet\Settings\SettingsController), Object(MailPoet\Util\License\Features\Subscribers), Object(MailPoet\Config\ServicesChecker), Object(MailPoet\Mailer\MailerFactory), Object(MailPoet\Util\Notices\SenderDomainAuthenticationNotices)) #1 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService() #2 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1) #3 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...') #4 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...') #5 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(194): require_once('/htdocs/wp-cont...') #6 /htdocs/wp-settings.php(526): include_once('/htdocs/wp-cont...') #7 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #8 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #9 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #10 /htdocs/index.php(17): require('/htdocs/wp-blog...') #11 {main} thrown in /htdocs/wp-content/plugins/mailpoet/lib/Util/Notices/PermanentNotices.php on line 91