|
getOrderingNumber() > 0) { return; } $replyTo = $this->config->get('replyto_email'); $bounce = $this->config->get('bounce_email'); $from = $this->config->get('from_email'); $forwardEmail = $replyTo != $bounce ? $replyTo : $from; if (empty($forwardEmail)) { $forwardEmail = acym_currentUserEmail(); } $forwardAction = acym_escapeDB(json_encode(['0' => 'delete_message', '1' => 'forward_message', 'forward_to' => $forwardEmail])); $query = "INSERT INTO `#__acym_rule` (`id`, `name`, `description`, `ordering`, `regex`, `executed_on`, `action_message`, `action_user`, `active`, `increment_stats`, `execute_action_after`) VALUES "; $query .= "(1, 'ACYM_LIST_UNSUBSCRIBE_HANDLING', 'ACYM_LIST_UNSUBSCRIBE_HANDLING_DESC', 1, 'Please unsubscribe user ID \\\\d+', '[\"body\"]', '[\"delete_message\"]', '[\"unsubscribe_user\"]', 1, 0, 0),"; $query .= "(2, 'ACYM_SUPPRESSION_LIST', 'ACYM_SUPPRESSION_LIST_DESC', 2, 'suppression list', '[\"body\"]', '[\"delete_message\"]', '[\"unsubscribe_user\",\"block_user\",\"empty_queue_user\"]', 1, 1, 0),"; $query .= "(3, 'ACYM_ACTION_REQUIRED', 'ACYM_ACTION_REQUIRED_DESC', 3, 'action *requ|verif', '[\"subject\"]', ".$forwardAction.", '[]', 1, 0, 0),"; $query .= "(4, 'ACYM_ACKNOWLEDGMENT_RECEIPT_SUBJECT', 'ACYM_ACKNOWLEDGMENT_RECEIPT_SUBJECT_DESC', 4, '(out|away) *(of|from)|vacation|vacanze|vacaciones|holiday|absen|congés|recept|acknowledg|thank you for|Auto *Response|Incident|Automati|Ticket|Resposta *automática', '[\"subject\"]', '[\"delete_message\"]', '[]', 1, 0, 0),"; $query .= "(5, 'ACYM_FEEDBACK_LOOP', 'ACYM_FEEDBACK_LOOP_DESC', 5, 'feedback|staff@hotmail.com|complaints@.{0,15}email-abuse.amazonses.com|complaint about message', '[\"senderInfo\",\"subject\"]', '[\"save_message\",\"delete_message\"]', '[\"unsubscribe_user\",\"block_user\",\"empty_queue_user\"]', 1, 0, 0),"; $query .= "(6, 'ACYM_FEEDBACK_LOOP_BODY', 'ACYM_FEEDBACK_LOOP_BODY_DESC', 6, 'Feedback-Type.{1,5}abuse', '[\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"unsubscribe_user\"]', 1, 1, 0),"; $query .= "(7, 'ACYM_MAILBOX_FULL', 'ACYM_MAILBOX_FULL_DESC', 7, '((mailbox|mailfolder|storage|quota|space|inbox) *(is)? *(over)? *(exceeded|size|storage|allocation|full|quota|maxi))|status(-code)? *(:|=)? *5.2.2|quota-issue|not *enough.{1,20}space|((over|exceeded|full|exhausted) *(allowed)? *(mail|storage|quota))|Space shortage', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; $query .= "(8, 'ACYM_BLOCKED_GOOGLE_GROUPS', 'ACYM_BLOCKED_GOOGLE_GROUPS_DESC', 8, 'message *rejected *by *Google *Groups', '[\"body\"]', '[\"delete_message\"]', '[\"block_user\"]', 1, 1, 3),"; $query .= "(9, 'ACYM_REJECTED', 'ACYM_REJECTED_DESC', 9, 'rejected *your *message|email *provider *rejected *it', '[\"body\"]', '[\"delete_message\"]', '[\"block_user\"]', 1, 1, 3),"; $query .= "(10, 'ACYM_MAILBOX_DOESNT_EXIST_1', 'ACYM_MAILBOX_DOESNT_EXIST_1_DESC', 10, '(Invalid|no such|unknown|bad|des?activated|inactive|unrouteable) *(mail|destination|recipient|user|address|person)|bad-mailbox|inactive-mailbox|not listed in.{1,20}directory|RecipNotFound|(user|mailbox|address|recipients?|host|account|domain) *(is|has been)? *(error|disabled|failed|unknown|unavailable|not *(found|available)|.{1,30}inactiv)|no *mailbox *here|user does.?n.t have.{0,30}account|no *longer *(active|working|in *use)|mail( *foi)? *desativado|recipient \'[^\']+\' not known', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; $query .= "(11, 'ACYM_MESSAGE_BLOCKED_RECIPIENTS', 'ACYM_MESSAGE_BLOCKED_RECIPIENTS_DESC', 11, 'blocked *by|block *list|look(ed)? *like *spam|spam-related|spam *detected| CXBL | CDRBL | IPBL | URLBL |(unacceptable|banned|offensive|filtered|blocked|unsolicited) *(content|message|e?-?mail)|service refused|(status(-code)?|554) *(:|=)? *5.7.1|administratively *denied|blacklisted *IP|policy *reasons|rejected.{1,10}spam|junkmail *rejected|throttling *constraints|exceeded.{1,10}max.{1,40}hour|comply with required standards|421 RP-00|550 SC-00|550 DY-00|550 OU-00|client *[0-9.]* *blocked *using', '[\"body\"]', ".$forwardAction.", '[\"block_user\"]', 1, 1, 3),"; $query .= "(12, 'ACYM_MAILBOX_DOESNT_EXIST_2', 'ACYM_MAILBOX_DOESNT_EXIST_2_DESC', 12, 'status(-? ?code)? *(:|=)? *(550)? *5.(1.[1-6]|0.0|4.[0123467])|recipient *(address *)?rejected|does *not *like *recipient|recipient *unknown *to *address|email *account *that *you *tried *to *reach *is *disabled|no *mail-enabled *subscriptions', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; $query .= "(13, 'ACYM_DOMAIN_NOT_EXIST', 'ACYM_DOMAIN_NOT_EXIST_DESC', 13, 'No.{1,10}MX *(record|host)|host *does *not *receive *any *mail|bad-domain|connection.{1,10}mail.{1,20}fail|domain.{1,10}not *exist|fail.{1,10}establish *connection|Unable *to *lookup *DNS *for|Unable *to *connect *to *remote *host', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; $query .= "(14, 'ACYM_TEMPORARY_FAILURES', 'ACYM_TEMPORARY_FAILURES_DESC', 14, 'has.*been.*delayed|delayed *mail|message *delayed|message-expired|temporar(il)?y *(failure|unavailable|disable|offline|unable)|deferred|delayed *([0-9]*) *(hour|minut)|possible *mail *loop|too *many *hops|delivery *time *expired|Action.php: *delayed|status(-code)? *(:|=)? *4.4.6|will continue to be attempted|unable to deliver in.*Status: 4.4.7|Connection *closed *unexpectedly', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 3),"; $query .= "(15, 'ACYM_FAILED_PERM', 'ACYM_FAILED_PERM_DESC', 15, 'failed *permanently|permanent.{1,20}(failure|error)|not *accepting *(any)? *mail|does *not *exist|no *valid *route|delivery *failure', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; $query .= "(16, 'ACYM_ACKNOWLEDGMENT_RECEIPT_BODY', 'ACYM_ACKNOWLEDGMENT_RECEIPT_BODY_DESC', 16, 'vacanc|holiday|vacation|absen|urlaub|ferie|feriado|vacanz|vacaciones|(out *of|not *in|outside)( *the)? *office|automatisch *(generierte)? *Antwort|confirm *we(\\'ve| *have) *received|den *Ferien|automática|RISPOSTA AUTOMATICA|vakantie|recepcionado *(su *)?requerimiento|Kiitos viestistäsi|nicht im Büro|nicht am Arbeitsplatz|automatic *reply|auto(-|mated *|matic *)reply|Email *has *been *recived|ricevuto *il *Suo *messaggio|ticket|poza *biurem|Automatic *respon|Case *Number|Αυτόματη *απάντηση', '[\"body\"]', '[\"delete_message\"]', '[]', 1, 0, 0),"; $query .= "(17, 'ACYM_FINAL_RULE', 'ACYM_FINAL_RULE_DESC', 17, '.', '[\"senderInfo\",\"subject\"]', ".$forwardAction.", '[]', 1, 0, 0);"; acym_query($query); $this->config->saveConfig(['bounceVersion' => self::BOUNCE_VERSION]); } public function installFields(): void { $query = "INSERT IGNORE INTO #__acym_field (`id`, `name`, `type`, `value`, `active`, `default_value`, `required`, `ordering`, `option`, `core`, `backend_edition`, `backend_listing`, `frontend_edition`, `frontend_listing`, `namekey`) VALUES (1, 'ACYM_NAME', 'text', NULL, 1, NULL, 0, 1, '{\"error_message\":\"\",\"error_message_invalid\":\"\",\"size\":\"\",\"rows\":\"\",\"columns\":\"\",\"format\":\"\",\"custom_text\":\"\",\"css_class\":\"\",\"authorized_content\":{\"0\":\"all\",\"regex\":\"\"}}', 1, 1, 1, 1, 1, 'acym_name'), (2, 'ACYM_EMAIL', 'text', NULL, 1, NULL, 1, 2, '{\"error_message\":\"\",\"error_message_invalid\":\"\",\"size\":\"\",\"rows\":\"\",\"columns\":\"\",\"format\":\"\",\"custom_text\":\"\",\"css_class\":\"\",\"authorized_content\":{\"0\":\"all\",\"regex\":\"\"}}', 1, 1, 1, 1, 1, 'acym_email');"; acym_query($query); $fieldClass = new FieldClass(); $fieldClass->insertLanguageField(); } public function installTemplates(): void { $mailClass = new MailClass(); $installedTemplates = 0; $templates = acym_getFolders(ACYM_BACK.'templates'.DS, '.', false, true); foreach ($templates as $oneTemplateFolderPath) { $templateName = substr($oneTemplateFolderPath, strrpos($oneTemplateFolderPath, DS) + 1); $templateName = str_replace('_', ' ', $templateName); $oneMail = $mailClass->getOneByName($templateName, false, MailClass::TYPE_TEMPLATE); if (!empty($oneMail)) { continue; } if ($mailClass->installExtractedTemplate($oneTemplateFolderPath, false)) { $installedTemplates++; } } if ($installedTemplates === 0) { acym_enqueueMessage(acym_translation('ACYM_DEFAULT_TEMPLATES_ALREADY_INSTALL'), 'info'); } } public function installDefaultAutomations(): void { $this->newAutomationAdmin('ACYM_ADMIN_USER_CREATE'); $this->newAutomationAdmin('ACYM_ADMIN_USER_MODIFICATION'); } public function installList(): void { $listClass = new ListClass(); $listClass->addDefaultList(); } public function installNotifications(): bool { $searchSettings = [ 'offset' => 0, 'mailsPerPage' => 9000, 'key' => 'name', ]; $mailClass = new MailClass(); $notifications = $mailClass->getMailsByType(MailClass::TYPE_NOTIFICATION, $searchSettings); $notifications = $notifications['mails']; $user = $this->getCurrentUser(); if (empty($user)) { return false; } $addNotif = []; // Email sent with the cron report if (empty($notifications['acy_report'])) { $addNotif[] = [ 'name' => 'acy_report', 'subject' => 'AcyMailing Cron Report {mainreport}', 'content' => '
{report}
{detailreport}
', ]; } // Confirmation email for double opt-in if (empty($notifications['acy_confirm'])) { $addNotif[] = [ 'name' => 'acy_confirm', 'subject' => '{subscriber:name|ucfirst}, {trans:ACYM_PLEASE_CONFIRM_SUBSCRIPTION}', 'content' => $this->getFormatedNotification( '{trans:ACYM_CONFIRM_MESSAGE}
{trans:ACYM_CONFIRM_MESSAGE_ACTIVATE}
{confirm}{trans:ACYM_CONFIRM_SUBSCRIPTION}{/confirm}
' ), ]; } if (empty($notifications['acy_notification_create'])) { $addNotif[] = [ 'name' => 'acy_notification_create', 'subject' => acym_translation('ACYM_NOTIFICATION_CREATE_SUBJECT').': {user:email}', 'content' => $this->getFormatedNotification( ''.acym_translation('ACYM_NOTIFICATION_CREATE_BODY').'
'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'
'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', 'julia@example.com').'
'.acym_translation('ACYM_SOURCE').': '.$this->getDTextDisplay('{user:source}', 'registration_form').'
'.acym_translation('ACYM_SUBSCRIPTION').': '.$this->getDTextDisplay('{user:subscription}', 'Newsletters - 2020-11-02 14:38:24').'
' ), ]; } if (empty($notifications['acy_notification_unsub'])) { $addNotif[] = [ 'name' => 'acy_notification_unsub', 'subject' => acym_translation('ACYM_NOTIFICATION_UNSUB_SUBJECT').': {user:email}', 'content' => $this->getFormatedNotification( ''.acym_translation('ACYM_NOTIFICATION_UNSUB_BODY').'
'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'
'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', 'julia@example.com').'
'.acym_translation('ACYM_LISTS').': '.$this->getDTextDisplay('{lists}', 'Newsletters, Tips').'
' ), ]; } if (empty($notifications['acy_notification_unsuball'])) { $addNotif[] = [ 'name' => 'acy_notification_unsuball', 'subject' => acym_translation('ACYM_NOTIFICATION_UNSUBALL_SUBJECT').': {user:email}', 'content' => $this->getFormatedNotification( ''.acym_translation('ACYM_NOTIFICATION_UNSUBALL_BODY').'
'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'
'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', 'julia@example.com').'
' ), ]; } if (empty($notifications['acy_notification_subform'])) { $addNotif[] = [ 'name' => 'acy_notification_subform', 'subject' => acym_translation('ACYM_NOTIFICATION_SUBFORM_SUBJECT').': {user:email}', 'content' => $this->getFormatedNotification( ''.acym_translation('ACYM_NOTIFICATION_SUBFORM_BODY').'
'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'
'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', 'julia@example.com').'
'.acym_translation('ACYM_SUBSCRIPTION').': '.$this->getDTextDisplay('{user:subscription}', 'Newsletters - 2025-11-02 14:38:24').'
' ), ]; } if (empty($notifications['acy_notification_profile'])) { $addNotif[] = [ 'name' => 'acy_notification_profile', 'subject' => acym_translation('ACYM_NOTIFICATION_PROFILE_SUBJECT').': {user:email}', 'content' => $this->getFormatedNotification( ''.acym_translation('ACYM_NOTIFICATION_PROFILE_BODY').'
'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'
'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', 'julia@example.com').'
'.acym_translation('ACYM_SUBSCRIPTION').': '.$this->getDTextDisplay('{user:subscription}', 'Newsletters - 2025-11-02 14:38:24').'
' ), ]; } if (empty($notifications['acy_notification_confirm'])) { $addNotif[] = [ 'name' => 'acy_notification_confirm', 'subject' => acym_translation('ACYM_NOTIFICATION_CONFIRM_SUBJECT').': {user:email}', 'content' => $this->getFormatedNotification( ''.acym_translation('ACYM_NOTIFICATION_CONFIRM_BODY').'
'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{user:name}', 'Julia').'
'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{user:email}', 'julia@example.com').'
'.acym_translation('ACYM_IP').': '.$this->getDTextDisplay('{user:confirmation_ip}', '127.0.0.1').'
'.acym_translation('ACYM_SUBSCRIPTION').': '.$this->getDTextDisplay('{user:subscription}', 'Newsletters - 2025-11-02 14:38:24').'
' ), ]; } if (empty($notifications['acy_notification_cms'])) { $addNotif[] = [ 'name' => 'acy_notification_cms', 'subject' => '{subject}', 'content' => '{body}', 'drag_editor' => 0, ]; } if (empty($notifications['acy_notification_auto_campaign_admin'])) { $addNotif[] = [ 'name' => 'acy_notification_auto_campaign_admin', 'subject' => acym_translation('ACYM_NOTIFICATION_AUTO_CAMPAIGN_SUBJECT'), 'content' => $this->getFormatedNotification( ''.acym_translation('ACYM_NOTIFICATION_AUTO_CAMPAIGN_BODY').'
' ), ]; } $firstEmail = $mailClass->getOneByName(acym_translation(self::FIRST_EMAIL_NAME_KEY)); if (empty($firstEmail)) { $body = '
|
'.acym_translation('ACYM_NEW_USER_ACYMAILING').':
'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{subscriber:name|info:current}', 'Roger').'
'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{subscriber:email|info:current}', 'roger@example.com').'
'; $adminModif = new \stdClass(); $adminModif->desc = 'ACYM_ADMIN_USER_MODIFICATION_DESC'; $adminModif->triggers = '{"user_modification":[""],"type_trigger":"user"}'; $adminModif->conditions = '{"type_condition":"user"}'; $adminModif->emailTitle = acym_translation('ACYM_SUBSCRIBER_MODIFICATION'); $adminModif->emailSubject = acym_translation('ACYM_SUBSCRIBER_MODIFICATION'); $adminModif->emailContent = ''.acym_translation('ACYM_USER_MODIFY_ACYMAILING').':
'.acym_translation('ACYM_NAME').': '.$this->getDTextDisplay('{subscriber:name|info:current}', 'Roger').'
'.acym_translation('ACYM_EMAIL').': '.$this->getDTextDisplay('{subscriber:email|info:current}', 'roger@example.com').'
'; $info = [ 'ACYM_ADMIN_USER_CREATE' => $adminCreate, 'ACYM_ADMIN_USER_MODIFICATION' => $adminModif, ]; $newAutomation = new \stdClass(); $newAutomation->name = acym_translation($title); $newAutomation->description = acym_translation($info[$title]->desc); $newAutomation->active = 0; $newAutomation->admin = 1; $newAutomation->id = $automationClass->save($newAutomation); if (empty($newAutomation->id)) { return; } $newStep = new \stdClass(); $newStep->name = acym_translation($title); $newStep->triggers = $info[$title]->triggers; $newStep->automation_id = $newAutomation->id; $newStep->id = $stepClass->save($newStep); if (empty($newStep->id)) { return; } $newCondition = new \stdClass(); $newCondition->step_id = $newStep->id; $newCondition->conditions = $info[$title]->conditions; $newCondition->id = $conditionClass->save($newCondition); if (empty($newCondition->id)) { return; } $mailAutomation = new \stdClass(); $mailAutomation->type = MailClass::TYPE_AUTOMATION; $mailAutomation->drag_editor = 1; $mailAutomation->creator_id = acym_currentUserId(); $mailAutomation->creation_date = gmdate('Y-m-d H:i:s', time()); $mailAutomation->name = acym_translation($info[$title]->emailTitle); $mailAutomation->subject = acym_translation($info[$title]->emailSubject); $mailAutomation->body = $this->getFormatedNotification($info[$title]->emailContent); $mailAutomation->id = $mailClass->save($mailAutomation); if (empty($mailAutomation->id)) { return; } $newAction = new \stdClass(); $newAction->condition_id = $newCondition->id; $newAction->actions = '[{"acy_add_queue":{"mail_id":"'.intval($mailAutomation->id).'","time":"[time]"}}]'; $newAction->filters = '{"0":{"1":{"acy_field":{"field":"email","operator":"=","value":"'.acym_currentUserEmail().'"}}},"type_filter":"classic"}'; $newAction->order = 1; $actionClass->save($newAction); } private function getDTextDisplay(string $dtext, string $preview): string { $display = ''; $display .= $preview; $display .= ''; $display .= ''; return $display; } private function getFormatedNotification(string $content): string { $beginning = '
|