Page 1 of 2

Wrong dates in Zimbra Webmail

Posted: Thu Mar 08, 2007 6:37 am
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!

Wrong dates in Zimbra Webmail

Posted: Thu Mar 08, 2007 10:13 am
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.

Wrong dates in Zimbra Webmail

Posted: Thu Mar 08, 2007 1:34 pm
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.

Wrong dates in Zimbra Webmail

Posted: Fri Mar 09, 2007 3:08 am
by urban@abak
this works for us. thanks a lot! ;)

Wrong dates in Zimbra Webmail

Posted: Fri Mar 09, 2007 9:14 am
by voltcraft
is there a way to use the /tb tailer for reindexing the mailbox?

Wrong dates in Zimbra Webmail

Posted: Fri Mar 09, 2007 11:14 am
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.

Wrong dates in Zimbra Webmail

Posted: Sat Mar 10, 2007 11:56 am
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

Wrong dates in Zimbra Webmail

Posted: Sat Mar 10, 2007 12:01 pm
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?

Wrong dates in Zimbra Webmail

Posted: Sat Mar 10, 2007 12:20 pm
by voltcraft
Without syncinternaldates it worked! Thanks!

Wrong dates in Zimbra Webmail

Posted: Thu Apr 30, 2009 4:09 am
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!