Applicable to:
- Plesk Onyx for Linux
Symptoms
-
Site Import extension was used to import mail in Domains > example.com > Mail Importing
-
After the messages are imported, Apple Mail shows date and time of import on these email messages
Cause
Apple Mail does not use Sent and Received information in mail headers, but uses the server's file system date, which was changed during mail importing. The request to improve product functionality and restore correct timestamps on import exists as #PMT-4559.
Resolution
As a workaround, apply the following:
Note: This solution will affect only newly downloaded messages. In case messages were downloaded beforehand, timestamps will not be updated.
-
Connect to the server via SSH
-
Ensure that the
patch
program is installed:# apt install patch -y 2>/dev/null || yum install patch -y
-
Download the patch file and unpack it:
# curl -LO https://plesk.zendesk.com/hc/article_attachments/360028740894/PMT-4559_linux.patch.tar.gz
# tar xf PMT-4559_linux.patch.tar.gz -
Apply the patch to the migrator backend:
# (cd / && patch -p0) <PMT-4559_linux.patch
Comments
11 comments
There seems some bugs...
1) the timestamp-change-script does not work on all mail files...
here is an example:
grep -m1 '^Date' "filename" | cut -d' ' -f3-
Feb 2018 15:16:34 +0100
... but... cat file manual ...
Date: 13 Feb 2018 15:16:34 +0100 ... so .. changing f3 to f2 gives
13 Feb 2018 15:16:34 +0100
but on other files f2 gives
Tue, 26 Mar 2019 11:42:00 +0100
file:
Date: Tue, 26 Mar 2019 11:42:00 +0100
so SOMETIMES there is a day included, sometimes not ! it seems to depends on the email client of the sender.
Some mails have the right file timestamp (i edited them manually) but does not show correctly in apple mail... it stays the import date
2) there seems different paths depending on plesk version / linux
'/usr/local/psa/admin/plib/modules/site-import/backend/lib/python/parallels/core/extras/mail-migrator/linux/plesk_mail_migrator/providers/maildir': No such file or directory
....
root@local:~# find / -name provider.py
/opt/psa/admin/plib/modules/wp-toolkit/vendor/plesk/plesk-migrator/backend/lib/python/parallels/core/extras/mail-migrator/linux/plesk_mail_migrator/providers/imap/provider.py
/opt/psa/admin/plib/modules/wp-toolkit/vendor/plesk/plesk-migrator/backend/lib/python/parallels/core/extras/mail-migrator/linux/plesk_mail_migrator/providers/maildir/provider.py
/opt/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/extras/mail-migrator/linux/plesk_mail_migrator/providers/imap/provider.py
/opt/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/extras/mail-migrator/linux/plesk_mail_migrator/providers/maildir/provider.py
i solved the problem by extracting the tar files of the mailnames manual and copy the existing files with rsync -a /extract_domain.tld/ /var/qmail/mailnames/domain.tld
by extracting the backup.tar with tar -xf all timestamps are correct. this is a huge plesk bug
@Peter Hansen,
The clients indeed may skip the day of week part of the date as specified in the RFC 2822: https://tools.ietf.org/html/rfc2822#section-3.3
Script was modified to extract the whole value of the 'Date:' header and process it.
The path of the module's files does not depend on the Plesk version. As noted in the article, this issue is related only to the Site Import extension, as it loads the messages through IMAP and does not preserve the timestamps.
From the output I see that only Plesk Migrator is installed on the server, the Migrator should not be affected by this issue: it transfers messages over `rsync` and packs data into archives, preserving original timestamps.
@Alexandr Bashurov,
I restore a backup of a domain and all timestamps where set to the restoration timepoint. This behaviour is also submitted here:
https://support.plesk.com/hc/en-us/articles/360020362873-File-timestamps-are-reset-upon-the-restoration-from-backup
Never the less, I got the same problem with the mailaccounts, because all files had the wrong timestamp. The correct timestamps are saved in the backup.tar archive. For me, it only works if I rsync the manual extracted files of the tar archive over the restored files. But I will try your updated version of the script later. Maybe it works now.
@Peter Hansen
Let us know the results, please. You may drop a comment here or create a request to our support as per https://support.plesk.com/hc/en-us/articles/213608509-How-to-submit-a-request-to-Plesk-support- if you want us to investigate the issue in more details. Thanks!
Again... Seems not to work !
1) File list
2) Script with Verbose = true
3) result of maildir with example cat
@Peter Hansen
Please note the following: by default, only messages created in the last 2 days will be modified. This is done to prevent changing timestamps on non-imported messages. It can be tweaked by setting a different value to the UPDATED_BEFORE variable in script.
Try changing the UPDATED_BEFORE="2" value to a higher one, for example, to 10 or 30.
If you have already changed this value, can you please tell me to which value? Thanks.
Hello, my mail is not at the standard location, and apparently the second option does not work then.
@Maarten Wilbers
You may edit the MAIL_D="/var/qmail/mailnames/" in the script to your mail location.
Why is the date extracted from the content of the mail?
No-one noticed that the first part of the filename is the date in linux-seconds?
EXTRACTEDDATE=`echo ${FILE##*/} | awk -F. '{print $1}'`
touch -d@${EXTRACTEDDATE} "${FILE}"
I have now restored all the modified dates, but things are still not in correct order...
Hello frater,
Such behavior with mail messages timestamps is known issue of Apple Mail described here:
https://discussions.apple.com/thread/2270537
The patch for Mail importing works perfectly for newly added emails. However, indeed it does no longer applied for already downloaded messages. It could happen due to changes on software side.
The information that workaround is not working now has been reported to our development team and they will continue improving product functionality. For know, you can remove messages with wrong timestamps and re-migrate them.
Article has been modified accordingly.
Please sign in to leave a comment.