@joeyk
To add more context I have developed a custom solution to allow scheduling of emails, so in front end user can add “schedule rows”, each holding specific number of how many contacts will be created each day (cron job running, executing 1 row every day).
See image:
Back-end is ready and working and some of it requires manipulations with leads
table and I also needed to edit some.php
files related to import.
This scheduling feature is fully working and doing its purpose, yet when email is sent to a person unsubscribe link click will not mark as Do not contact
.
Simplified flow of scheduling feature:
-
Contacts are imported (user leaves empty segment field but adds segment_name column in csv and during import mapps segment_name column with segment_name field)
-
back-end is changed in a way to import into customleads table which is exactly identical to leads table. (Nothing goes into leads table from import directly)
-
Cron job is running executing every day, moving specified number of rows from customleads into leads and deleting moved ones from customleads.
-
segment with pre-defined filter segment_name custom filed equals to segment12
will accumulate those moved contacts in segment12 (this is example segment).
-
campaign built on top of segment12 will send emails to moved contacts/leads.
Issue related findings:
Now my findings are that in working default mautic instance (community 4.4.10 version) where unsubscribe works if I do following actions and send email, then ‘do not contact’ will work.
Those actions were chosen accordingly to showcase approximately similar flow of scheduling feature.
Action 1:
INSERT INTO leads (email, is_published, points, segment_name, owner_id, title, firstname, stage_id, date_added, date_identified, last_active, created_by_user, modified_by_user) VALUES ("realUserEmail@yahoo.com", 1, 0, "segment12", 1, "eaxmpletitle", "Iuri", NULL, '2024-10-21 15:14:15', '2024-10-21 15:14:15', '2024-10-21 15:14:15', NULL, NULL);
This will safely make that contact appear inside Mautic contacts page.
Action 2:
sudo /usr/bin/php /home/realDomain/domains/subserver.realDomain/public_html/bin/console mautic:segments:update
After this action that inserted contact will appear in segment12
which has filter checking for custom field of segment_name equals to ‘segment12’
Action 3:
mautic:campaigns:trigger
Email will be sent to user and once unsubscribe link is clicked contact history will immediately show that contact was marked as Do not contact
Important finding:
When I replicated all actions from above on server which has scheduling feature, only thing that was different is that contact was not marked as Do not contact
Now since for scheduling feature I only changed back-end for Import related .php files, this strongly suggests to me that the problem is some misconfigurations or user ownerships of this server
Important comment: it might confuse you why do I have segment_name
custom field
, but with current back-end it is necessary to make things work fully. So for now with scheduling feature when importing contacts, they must include segment_name column which will be used to determine future segment, since scheduling feature does not support segment mapping yet.