maildir标题问题 [英] maildir headers problem

查看:184
本文介绍了maildir标题问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的bash脚本来更新maildir文件的mtimes:

 #!/ bin / bash 

for in in / test / emailfile

do
date = $(sed -n'/ Received:from / {:a; n; /; / {s /。 *; // p; q}; ba}'$ i)
newdate = $(date -d$ date+'%Y%m%d%H%M.%S')
touch -t$ newdate$ i
done

此脚本一直工作正常,标准标题如下:

 交货日期:Sun,2007年4月22日00:15:13  - 0600 
收到:从an-out-0708.google.com([209.85.132.243])
由x.xxxx.com与esmtp(Exim 4.63)
(envelope- from< xxxxxx@gmail.com>)
id为x@xxxxx.com的1HfVLs-0002Io-RQ
;太阳,2007年4月22日00:15:13 -0600

哪个有2007年交货日期。如果我触摸该文件,所以文件日期是从今天起,然后运行我的脚本,文件日期将恢复到从日期收到。



但是,当尝试运行我的脚本在电子邮件与以下标题:

 交货日期:2008年12月15日,星期一17:26:37  - 0800 
收到:从xxxxxx([130.194.13.165])
由xxxxxxx与esmtp(Exim 4.69)
(信封来自< xxxxxi@xxxxx.xxx.xx>)
id 1LCOhp-0006fm-2g
for xxxxx@xxxxxx.com;星期一,2008年12月15日17:26:37 -0800

日期不可恢复。我看不到标题在任何方面明显不同。我需要重置mtimes,因为许多邮件客户端使用文件时间显示为从时间接收。我的脚本已经处理了超过3000封电子邮件,确保所有客户以正确的顺序显示电子邮件,以便移动服务器和所有具有相同日期的文件,但由于某种原因,它不会在特定的电子邮件中起作用。我是否从脚本中留下了明显的东西?



编辑:日期显然是从脚本恢复的,但是依赖mtimes的客户端不会显示此消息,无论什么脚本将日期设置为。权限与布局和文件名格式相同。以下是ls -la的帖子

  -rw-rw ---- 1 username username 11769 Dec 14 21:25 1229318728 .H329820P11297.xxxxx.serverxxxxx.com:2,S 
-rw-rw ---- 1用户名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

无法正确显示的文件是从顶部的第二。有没有办法调试为什么会发生这种情况?

解决方案

这似乎对我来说很好,尝试这个小小的看看你得到什么。

 #!/ bin / bash 
echo'交货日期: 2007 00:15:13 -0600
收到:从an-out-0708.google.com([209.85.132.243])
由x.xxxx.com与esmtp(Exim 4.63)
(信封来自< xxxxxx@gmail.com>)
id xf@lixi.com的ifVLs-0002Io-RQ
;太阳,2007年4月22日00:15:13 -0600'| sed -n'/ Received:from / {:a; N; /; / {s /.*; //磷; Q}; ba}'
date -dSun,2007年4月22日00:15:13 -0600+'%Y%m%d%H%M.%S'
echo'交货日期: 2008年12月15日,星期一17:26:37 -0800
收到:从xxxxxx([130.194.13.165])
由xxxxxxx与esmtp(Exim 4.69)
(信封来自< xxxxxi @ xxxxx.xxx.xx>)
id 1LCOhp-0006fm-2g
for xxxxx@xxxxxx.com; 2008年12月15日,星期一17:26:37 -0800'| sed -n'/ Received:from / {:a; N; /; / {s /.*; //磷; Q}; ba}'
date -d2008年12月15日,星期一17:26:37 -0800+%Y%m%d%H%M.%S'

我得到(如预期):

 太阳,2007年4月22日00:15:13 -0600 
200704221415.13
2008年12月15日,星期一17:26:37 -0800
200812161026.37
/ pre>

所以我不知道为什么你的工作不起作用,尽管该脚本的输出应该是一个很好的起点。



您可以做的另一件事是暂时修改您的脚本,如下所示:

 :::: :
echo touch -t$ newdate$ i
touch -t$ newdate$ i
::::

这将输出您正在尝试的实际命令。



还要检查文件权限在目录和单个文件上。



ls -l(mtime)和ls -lc(ctime)是什么给你实际的可疑邮件文件?可能您的脚本工作正常,用户电子邮件客户端不使用mtime / ctime。



编辑后:



引用但是,无论脚本将日期设置为何时,依赖于mtimes的客户端都不会显示此消息,我的回复是客户端依赖于mtimes。一旦你已经消除了所有其他的可能性,那么任何剩下的东西,不论怎样,都必须这样。有一件事我注意到:你刚才说这个消息根本没有被显示(或者说我们以为我们在说的是错误的日期)?



如果是后者,你需要查看邮件客户端,看看它实际上是从哪个日期开始。只是出于兴趣,客户认为是什么日期(它是否匹配标题中的任何日期?



如果前者是另一个问题,我们可以讨论



我认为(客户端)需要从这里开始,由于我的专业知识比脚本比电子邮件客户端更多,我可能无法帮助然而,我有兴趣看看它是如何发生的,所以我会喜欢这个问题。


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 <xxxxxx@gmail.com>)
    id 1HfVLs-0002Io-RQ
    for x@xxxxx.com; 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 <xxxxxi@xxxxx.xxx.xx>)
    id 1LCOhp-0006fm-2g
    for xxxxx@xxxxxx.com; 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?

解决方案

It appears to work fine for me, try this little ditty and see what you get.

#!/bin/bash
echo '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 <xxxxxx@gmail.com>)
    id 1HfVLs-0002Io-RQ
    for x@xxxxx.com; Sun, 22 Apr 2007 00:15:13 -0600' | sed -n '/Received: from/ { :a; n; /;/ {s/.*; //p;q}; b a }'
date -d "Sun, 22 Apr 2007 00:15:13 -0600" +'%Y%m%d%H%M.%S'
echo '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 <xxxxxi@xxxxx.xxx.xx>)
    id 1LCOhp-0006fm-2g
    for xxxxx@xxxxxx.com; Mon, 15 Dec 2008 17:26:37 -0800' | sed -n '/Received: from/ { :a; n; /;/ {s/.*; //p;q}; b a }'
date -d "Mon, 15 Dec 2008 17:26:37 -0800" +'%Y%m%d%H%M.%S'

I get (as expected):

Sun, 22 Apr 2007 00:15:13 -0600
200704221415.13
Mon, 15 Dec 2008 17:26:37 -0800
200812161026.37

So I'm not sure why yours isn't working, although the output of that script should be a good starting point.

The other thing you can do is temporarily modify your script as follows:

: : : : :
echo touch -t "$newdate" "$i"
touch -t "$newdate" "$i"
: : : : :

This will output the actual command you're trying.

Also check file permissions on the directory and individual files.

What does "ls -l" (mtime) and "ls -lc" (ctime) give you on the actual suspect mail file? It may be that your script is working fine vut the users email client is not using the mtime/ctime.

After edit:

Quoting "however clients that rely on mtimes will not display this message regardless of what the script sets the date to", my response is that the client is not relying on mtimes.

Paraphrasing Sherlock himself, once you have eliminated all the other possibilities, whatever's left, however unlikely, must be the case. And one thing I noticed: did you just state that the message isn't being displayed at all (or that it's got the wrong date as I've thought we were talking about)?

If the latter, you need to look into the mail client to see where it's actually getting its date from. Just out of interest, what date does the client think it is (and does it match any date within the header?

If the former, that's a different problem we can discuss.

I think that's (the client) where you need to go from here and, since my expertise is more in scripting than email clients, I may not be able to help further. Still, I'm interested to see how it turns out, so I'll favorite this question.

这篇关于maildir标题问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆