Skip to content

Commit

Permalink
Merge pull request #31608 from masetto/temporary-error
Browse files Browse the repository at this point in the history
"Domain not found" error (error code 450 - class 4.1.2) is not a temporary error
  • Loading branch information
demeritcowboy authored Dec 23, 2024
2 parents e418ede + ed388eb commit 72cdaf2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions CRM/Admin/Form/Preferences/Mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences {
'url_tracking_default' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'open_tracking_default' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'scheduled_reminder_smarty' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'smtp_450_is_permanent' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
];

public function postProcess() {
Expand Down
8 changes: 8 additions & 0 deletions ext/flexmailer/src/Listener/DefaultSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ protected function isTemporaryError($message) {
return FALSE;
}

// Consider SMTP Erorr 450, class 4.1.2 "Domain not found", as permanent failures if the corresponding setting is enabled
if ($code === '450' && \Civi::settings()->get('smtp_450_is_permanent')) {
$class = preg_match('/ \(code: (.+), response: ([0-9\.]+) /', $message, $matches) ? $matches[2] : '';
if ($class === '4.1.2') {
return FALSE;
}
}

if (str_contains($message, 'Failed to set sender')) {
return TRUE;
}
Expand Down
16 changes: 16 additions & 0 deletions settings/Mailing.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,4 +455,20 @@
'description' => ts('Controls whether scheduled reminders will attempt to process smarty tokens.'),
'help_text' => NULL,
],
'smtp_450_is_permanent' => [
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'smtp_450_is_permanent',
'type' => 'Boolean',
'html_type' => 'checkbox',
'quick_form_type' => 'CheckBox',
'default' => 0,
'title' => ts('Treat SMTP Error 450 4.1.2 as permanent'),
'add' => '5.80',
'is_domain' => 1,
'is_contact' => 0,
'description' => ts('Consider domains that will not resolve (SMTP Error 450 - class 4.1.2 "Domain not found") as permanent failures.'),
'help_text' => NULL,
'help' => ['id' => 'smtp_450_is_permanent'],
],
];
6 changes: 6 additions & 0 deletions templates/CRM/Admin/Form/Preferences/Mailing.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@
<p>{ts}Specify an Email From Address to use when the system sends an email but a reply is not expected, for example when a user is sent an email for a double opt-in.{/ts}</p>
<p>{ts}Leaving this blank will use the default which will be do-not-reply@default_domain where the default_domain will be the email domain address of your default mailing account also used for bounce handling.{/ts}</p>
{/htxt}
{htxt id="smtp_450_is_permanent-title"}
{ts}Treat SMTP Error 450 4.1.2 as permanent.{/ts}
{/htxt}
{htxt id="smtp_450_is_permanent"}
<p>{ts}Some SMTP servers are configured to not accept an email if the recipient cannot be reached. Most of the time it means that the domain doesn't exist at all and the SMTP server returns a 5xx permanent error. But sometimes the domain name is actually registered but its name servers are not reachable, or they don't give a meaningful answer. In these cases the SMTP server returns a 450 temporary delivery error and the mailing job gets stuck in status Running. Enabling this option will consider them as permanent failures.{/ts}</p>
{/htxt}

1 comment on commit 72cdaf2

@Ferrarilambo1020
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ley de la gravedad

Please sign in to comment.