Improve the DMARC error message

When the DMARC error message is displayed, add the sentence Click here to start the authentication. This will be a link that opens the verify domain dialogue

MAILPOET-4311
This commit is contained in:
Oluwaseun Olorunsola
2022-07-24 16:17:42 +01:00
committed by Veljko V
parent f97ca0e11e
commit c1f5ddf96e
2 changed files with 49 additions and 3 deletions

View File

@ -23,6 +23,8 @@ class MailPoetMapper {
const METHOD = Mailer::METHOD_MAILPOET;
const TEMPORARY_UNAVAILABLE_RETRY_INTERVAL = 300; // seconds
// Bridge message from https://github.com/mailpoet/services-bridge/blob/a3fbf0c1a88abc77840f9ec9f3965e632ce7d8b5/api/messages.rb#L16
const MAILPOET_BRIDGE_DMRAC_ERROR = "Email violates Sender Domain's DMARC policy. Please set up sender authentication.";
/** @var Bridge */
private $bridge;
@ -76,7 +78,11 @@ class MailPoetMapper {
$resultParsed = json_decode($result['message'], true);
$message = __('Error while sending.', 'mailpoet');
if (!is_array($resultParsed)) {
$message .= ' ' . $result['message'];
if ($result['message'] === self::MAILPOET_BRIDGE_DMRAC_ERROR) {
$message .= $this->getDmarcMessage($result, $sender);
} else {
$message .= ' ' . $result['message'];
}
break;
}
try {
@ -178,6 +184,25 @@ class MailPoetMapper {
return "{$message}<br/>";
}
private function getDmarcMessage($result, $sender): string {
$messageToAppend = __('[link1]Click here to start the authentication[/link1].', 'mailpoet');
$senderEmail = $sender['from_email'] ?? '';
$appendMessage = Helpers::replaceLinkTags(
$messageToAppend,
'#',
[
'class' => 'mailpoet-js-button-authorize-email-and-sender-domain',
'data-email' => $senderEmail,
'data-type' => 'domain',
'rel' => 'noopener noreferrer',
],
'link1'
);
$final = ' ' . $result['message'] . ' ' . $appendMessage;
return $final;
}
private function getEmailVolumeLimitReachedMessage(): string {
$partialApiKey = $this->servicesChecker->generatePartialApiKey();
$emailVolumeLimit = $this->subscribersFeature->getEmailVolumeLimit();