Hello,
I have the followign bash script to update mtimes for maildir files:
#!/bin/bash
for i in /test/emailfile
do
date=$(sed -n '/Received: from/ { :a; n; /;/ {s/.*; //p;q}; b a }' "$i")
newdate=$(date -d "$date" +'%Y%m%d%H%M.%S')
touch -t "$newdate" "$i"
done
This script has always worked fine, with standard headers like these:
Delivery-date: Sun, 22 Apr 2007 00:15:13 -0600
Received: from an-out-0708.google.com ([209.85.132.243])
by x.xxxx.com with esmtp (Exim 4.63)
(envelope-from <[email protected]>)
id 1HfVLs-0002Io-RQ
for [email protected]; Sun, 22 Apr 2007 00:15:13 -0600
Which has a 2007 delivery date. If I touch that file so the file date is from today, and then run my script, the file date is restored to the received from date.
However, when attempting to run my script on an email with the following headers:
Delivery-date: Mon, 15 Dec 2008 17:26:37 -0800
Received: from xxxxxx ([130.194.13.165])
by xxxxxxx with esmtp (Exim 4.69)
(envelope-from <[email protected]>)
id 1LCOhp-0006fm-2g
for [email protected]; Mon, 15 Dec 2008 17:26:37 -0800
The date is apparantly not restored. I can not see that the headers are obviously different in any way. I need to reset the mtimes, because many mail clients use the filetime to display as the received from time. My script has worked on over 3000 emails, ensuring all clients displays the emails in the right order aftr moving servers and all files having the same date, but for some reason it will not work on a particular email. Have I left something obvious out of the script?
edit: the date is apparently restored from the script, however clients that rely on mtimes will not display this message regardless of what the script sets the date to. The permissions are the same, as is the layout and filename format. Below is a posting from ls -la
-rw-rw---- 1 username username 11769 Dec 14 21:25 1229318728.H329820P11297.xxxxx.serverxxxxx.com:2,S
-rw-rw---- 1 username username 3366 Dec 15 17:26 1229390797.H476913P25671.xxxxx.serverxxxxx.com:2,S
-rw-rw---- 1 username username 1149 Dec 22 05:39 1229953142.H901034P11016.xxxxx.serverxxxxx.com:2,S
-rw-rw---- 1 username username 7557 Dec 23 15:43 1230075791.H700954P8392.xxxxx.serverxxxxx.com:2,S
The file that will not display correctly is the second from the top. Is there any way to debug why this is happening at all?