Wrong dates in Zimbra Webmail

Looking to migrate to ZCS? Ask here. Got a great tip or script that helped you migrate? Post it here.
voltcraft
Posts: 22
Joined: Fri Sep 12, 2014 10:28 pm

Wrong dates in Zimbra Webmail

Post by voltcraft »

Hii,
today I noticed that my imported mails with imapsync from an existing courier imap server have the wrong received date.
I thought that --syncinternaldates didn't work but then I saw that zimbra stored the correct date on the right side of the sender's address.
Sent by: foo@bar.at On:
Is there an option in zimbra to list the correct date in the received colum? Also the search option didn't work with the correct dates...
It seems that only the database has the wrong dates, all flatfiles have the correct date field in the mailheader.
I did a reindex of my mailbox but this didn't help, wrong date again... What else can I do?
Thanks!
urban@abak
Posts: 43
Joined: Fri Sep 12, 2014 10:22 pm

Wrong dates in Zimbra Webmail

Post by urban@abak »

we have a very similar problem... we're synchronizing with outlook via Outlook Connector. the files were first imported in outlook from the *.zdb file and then synchronized... the dates are displayed wrong in zimbra web mail(only).
if we set up the account in thunderbird and access it via imap, the dates are correct, so i guess the problem is somewhere in zimbra or is this maybe a system thing??
the system clock is set up right i guess as it shows the correct time and is in UTC, date is also correct. are there any commands to fix this? is this somewhere in the database or what is this???
this is zimbra NE 4.5.3 on SUSE9.
dkarp
Elite member
Elite member
Posts: 1410
Joined: Fri Sep 12, 2014 9:52 pm

Wrong dates in Zimbra Webmail

Post by dkarp »

voltcraft wrote:today I noticed that my imported mails with imapsync from an existing courier imap server have the wrong received date.
I thought that --syncinternaldates didn't work but then I saw that zimbra stored the correct date on the right side of the sender's address.
It sounds like --syncinternaldates didn't work. The best way around this is to re-import via imapsync, but import to "user@example.com/tb" instead of "user@example.com". This trailing "/tb" forces the Zimbra IMAP server to look at the Date header instead of looking at the INTERNALDATE during the import.
urban@abak
Posts: 43
Joined: Fri Sep 12, 2014 10:22 pm

Wrong dates in Zimbra Webmail

Post by urban@abak »

this works for us. thanks a lot! ;)
voltcraft
Posts: 22
Joined: Fri Sep 12, 2014 10:28 pm

Wrong dates in Zimbra Webmail

Post by voltcraft »

is there a way to use the /tb tailer for reindexing the mailbox?
dkarp
Elite member
Elite member
Posts: 1410
Joined: Fri Sep 12, 2014 9:52 pm

Wrong dates in Zimbra Webmail

Post by dkarp »

[quote user="voltcraft"]is there a way to use the /tb tailer for reindexing the mailbox?[/QUOTE]

No. We tag a "received" date on a message when it's added to the system. Reindexing just regenerates the fulltext Lucene index for searching and doesn't alter that date.
voltcraft
Posts: 22
Joined: Fri Sep 12, 2014 10:28 pm

Wrong dates in Zimbra Webmail

Post by voltcraft »

Today I tried a new import of my mailbox but it didn't work..
I used this command:
imapsync --nosyncacls --subscribe --syncinternaldates --host1 10.0.0.2 --user1 rene --password1 xxx --host2 localhost --user2 rene@youthtec.at/tb --password2 xxx
dkarp
Elite member
Elite member
Posts: 1410
Joined: Fri Sep 12, 2014 9:52 pm

Wrong dates in Zimbra Webmail

Post by dkarp »

[quote user="voltcraft"]Today I tried a new import of my mailbox but it didn't work..
imapsync --nosyncacls --subscribe --syncinternaldates --host1 10.0.0.2 --user1 rene --password1 xxx --host2 localhost --user2 rene@youthtec.at/tb --password2 xxx[/QUOTE]

Can you elaborate on that? What didn't work?
And does it work if you use the "/tb" suffix but leave off --syncinternaldates?
voltcraft
Posts: 22
Joined: Fri Sep 12, 2014 10:28 pm

Wrong dates in Zimbra Webmail

Post by voltcraft »

Without syncinternaldates it worked! Thanks!
ChaosFreak
Posts: 11
Joined: Sat Sep 13, 2014 12:22 am

Wrong dates in Zimbra Webmail

Post by ChaosFreak »

Got it to work with a shell script!
I was having the same problem, and I must admit this post was very helpful along with some other posts I found on Google regarding how to use imapsync.
However, I tried all of the suggestions here and still I was getting the wrong date on all my imported e-mails. Basically, they were assigned a timestamp of when I actually performed the import.
I did a lot of testing, and I figured out that you actually have to change the timestamp of the file itself. In Linux, you can use the touch -d "date/time string" command.
I wrote a shell script that recursively goes through all of the e-mails in the mail store, extracts the data from the "Date:" header, and then changes the timestamp of the file. Please see the code below:
#!/bin/bash
# This script changes the file timestamp to be the same as the date/time

# in the Date: header of the email. This solves problems on mail systems

# such as Zimbra where the date/time is changed to the current date/time

# when you import mail using imapsync.
# Questions/Comments: Jim Ryan
ROOTDIR=""
if [ -n "$1" ]; then

$ROOTDIR="$*"

fi
printf "Enter mailbox root directory [%s]: " "$ROOTDIR" > /dev/stdout

read ROOTDIR
while [ ! -d "$ROOTDIR" ]; do

echo "Not a valid directory."

printf "Enter mailbox root directory [%s]: " "$ROOTDIR" > /dev/stdout

read ROOTDIR

done
TMPFILE=`mktemp /tmp/fix_imap_dates.XXXXXXXXX` || exit 1

printf "Temporary file %s created.
" "$TMPFILE"
find $ROOTDIR -type f -printf "%p
" 2>/dev/null > "$TMPFILE"
exec 3
if [ -z "$GREPRESULT" ]; then

printf "File not an email or has no Date header: %s
" "$FILENAME"

else

DATETIME=`echo "$GREPRESULT" | sed 's/^Date: *//g'`

printf "Date for Timestamp is: %s
" "$DATETIME"

touch -d "$DATETIME" "$FILENAME"

fi

done
After this, I simply used imapsync without the "/tb" option but with the --syncinternaldates option.
sudo imapsync --nosyncacls --subscribe --syncinternaldates --host1 localhost --user1 xxxx --host2 http://www.xxxx.com --user2 xxx --ssl2 --port2 993 --noauthmd5


This all worked perfectly!
Post Reply