You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ponymail.apache.org by GitBox <gi...@apache.org> on 2021/09/18 15:39:28 UTC
[GitHub] [incubator-ponymail-foal] Humbedooh opened a new pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Humbedooh opened a new pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58
This expands the way we deal with missing or ínvalid date headers, by:
- looking for an envelope From header, and if possible, using the date from there
- if no valid From envelope, search the Received headers for a useful date
- if still nothing, fall back to current time and date.
This should address #56. I've tested with emails missing all three fields (sets to NOW), the Date field only (uses the From envelope header), and missing both Date and FROM (uses Received headers then).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] Humbedooh commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
Humbedooh commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711769212
##########
File path: tools/archiver.py
##########
@@ -920,6 +935,11 @@ def main():
help="If pushing to ElasticSearch fails, dump documents in JSON format to this directory and "
"fail silently.",
)
+ parser.add_argument(
+ "--defaultdate",
Review comment:
it's currently 'skip' to skip, and leave out the arg to use default behavior which is current date. I think this is reasonable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] sebbASF commented on pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
sebbASF commented on pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#issuecomment-922332368
It would be helpful to add the tests to the repo
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] sebbASF merged pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
sebbASF merged pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] sebbASF commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
sebbASF commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711608400
##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
message_date = email.utils.parsedate_tz(
str(msg_metadata.get("archived-at"))
)
-
if not message_date:
- epoch = time.time()
+ print("No message date could be derived from the Date: header, looking elsewhere.")
+ # See if we have a "From" header line in the raw email, we can use
+ first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+ if first_line.startswith("From "):
+ # If we have one, the date must be the third element when splitting by single space.
+ env_from_date = first_line.split(" ", 2)[-1] # Split twice, grab last element.
+ message_date = email.utils.parsedate_tz(env_from_date)
+ if message_date:
+ print("Found date in envelope FROM header: %s" % env_from_date)
+ # Otherwise, look for a Received: header we can scan
+ if not message_date:
+ for recv_from in msg.get_all('received', []): # We may have multiple of these, not all have "from".
+ m = re.match(r"from[^;]+?;\s+(.+?)(?:$|[\r\n])", recv_from)
+ if m:
+ message_date = email.utils.parsedate_tz(m.group(1))
+ if message_date:
+ print("Found date in Received header: %s" % m.group(1))
+ break
+ if not message_date:
+ print("Could not find any valid dates in email headers, using current time")
+ epoch = time.time()
+ else:
+ epoch = email.utils.mktime_tz(message_date)
notes.append(["BADDATE: Email date missing or invalid, setting to %u" % epoch])
- print(
Review comment:
If the date is invalid, it might be worth adding it to the note
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] sebbASF commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
sebbASF commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711609595
##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
message_date = email.utils.parsedate_tz(
str(msg_metadata.get("archived-at"))
)
-
if not message_date:
- epoch = time.time()
+ print("No message date could be derived from the Date: header, looking elsewhere.")
+ # See if we have a "From" header line in the raw email, we can use
+ first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+ if first_line.startswith("From "):
+ # If we have one, the date must be the third element when splitting by single space.
+ env_from_date = first_line.split(" ", 2)[-1] # Split twice, grab last element.
+ message_date = email.utils.parsedate_tz(env_from_date)
+ if message_date:
+ print("Found date in envelope FROM header: %s" % env_from_date)
+ # Otherwise, look for a Received: header we can scan
+ if not message_date:
+ for recv_from in msg.get_all('received', []): # We may have multiple of these, not all have "from".
+ m = re.match(r"from[^;]+?;\s+(.+?)(?:$|[\r\n])", recv_from)
+ if m:
+ message_date = email.utils.parsedate_tz(m.group(1))
+ if message_date:
+ print("Found date in Received header: %s" % m.group(1))
+ break
+ if not message_date:
+ print("Could not find any valid dates in email headers, using current time")
+ epoch = time.time()
+ else:
+ epoch = email.utils.mktime_tz(message_date)
notes.append(["BADDATE: Email date missing or invalid, setting to %u" % epoch])
- print(
Review comment:
Obviously only show it if it exists. Best not to conflate the two errors.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] sebbASF commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
sebbASF commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711608211
##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
message_date = email.utils.parsedate_tz(
str(msg_metadata.get("archived-at"))
)
-
if not message_date:
- epoch = time.time()
+ print("No message date could be derived from the Date: header, looking elsewhere.")
+ # See if we have a "From" header line in the raw email, we can use
+ first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+ if first_line.startswith("From "):
+ # If we have one, the date must be the third element when splitting by single space.
+ env_from_date = first_line.split(" ", 2)[-1] # Split twice, grab last element.
+ message_date = email.utils.parsedate_tz(env_from_date)
+ if message_date:
+ print("Found date in envelope FROM header: %s" % env_from_date)
+ # Otherwise, look for a Received: header we can scan
+ if not message_date:
+ for recv_from in msg.get_all('received', []): # We may have multiple of these, not all have "from".
+ m = re.match(r"from[^;]+?;\s+(.+?)(?:$|[\r\n])", recv_from)
+ if m:
+ message_date = email.utils.parsedate_tz(m.group(1))
+ if message_date:
+ print("Found date in Received header: %s" % m.group(1))
+ break
+ if not message_date:
+ print("Could not find any valid dates in email headers, using current time")
+ epoch = time.time()
Review comment:
Is the current time the correct fallback here?
If so, then add an explanatory comment to the code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] sebbASF commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
sebbASF commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711614226
##########
File path: tools/archiver.py
##########
@@ -920,6 +935,11 @@ def main():
help="If pushing to ElasticSearch fails, dump documents in JSON format to this directory and "
"fail silently.",
)
+ parser.add_argument(
+ "--defaultdate",
Review comment:
Given that the value is treated as an epoch, why no call it defaultepoch?
There might be a use-case for the defaulting to the current time: that is no longer possible.
Given that epoch cannot be negative, maybe use -1 for skip and -2 for current time?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] sebbASF commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
sebbASF commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711608311
##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
message_date = email.utils.parsedate_tz(
str(msg_metadata.get("archived-at"))
)
-
if not message_date:
- epoch = time.time()
+ print("No message date could be derived from the Date: header, looking elsewhere.")
+ # See if we have a "From" header line in the raw email, we can use
+ first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+ if first_line.startswith("From "):
+ # If we have one, the date must be the third element when splitting by single space.
+ env_from_date = first_line.split(" ", 2)[-1] # Split twice, grab last element.
+ message_date = email.utils.parsedate_tz(env_from_date)
+ if message_date:
+ print("Found date in envelope FROM header: %s" % env_from_date)
+ # Otherwise, look for a Received: header we can scan
+ if not message_date:
+ for recv_from in msg.get_all('received', []): # We may have multiple of these, not all have "from".
+ m = re.match(r"from[^;]+?;\s+(.+?)(?:$|[\r\n])", recv_from)
+ if m:
+ message_date = email.utils.parsedate_tz(m.group(1))
+ if message_date:
Review comment:
Parse errors?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] Humbedooh commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
Humbedooh commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711615218
##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
message_date = email.utils.parsedate_tz(
str(msg_metadata.get("archived-at"))
)
-
if not message_date:
- epoch = time.time()
+ print("No message date could be derived from the Date: header, looking elsewhere.")
+ # See if we have a "From" header line in the raw email, we can use
+ first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+ if first_line.startswith("From "):
+ # If we have one, the date must be the third element when splitting by single space.
+ env_from_date = first_line.split(" ", 2)[-1] # Split twice, grab last element.
+ message_date = email.utils.parsedate_tz(env_from_date)
+ if message_date:
+ print("Found date in envelope FROM header: %s" % env_from_date)
+ # Otherwise, look for a Received: header we can scan
+ if not message_date:
+ for recv_from in msg.get_all('received', []): # We may have multiple of these, not all have "from".
+ m = re.match(r"from[^;]+?;\s+(.+?)(?:$|[\r\n])", recv_from)
+ if m:
+ message_date = email.utils.parsedate_tz(m.group(1))
+ if message_date:
+ print("Found date in Received header: %s" % m.group(1))
+ break
+ if not message_date:
+ print("Could not find any valid dates in email headers, using current time")
+ epoch = time.time()
+ else:
+ epoch = email.utils.mktime_tz(message_date)
notes.append(["BADDATE: Email date missing or invalid, setting to %u" % epoch])
- print(
Review comment:
I've added in some extra notes along the process
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] Humbedooh commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
Humbedooh commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711608745
##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
message_date = email.utils.parsedate_tz(
str(msg_metadata.get("archived-at"))
)
-
if not message_date:
- epoch = time.time()
+ print("No message date could be derived from the Date: header, looking elsewhere.")
+ # See if we have a "From" header line in the raw email, we can use
+ first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+ if first_line.startswith("From "):
+ # If we have one, the date must be the third element when splitting by single space.
+ env_from_date = first_line.split(" ", 2)[-1] # Split twice, grab last element.
+ message_date = email.utils.parsedate_tz(env_from_date)
+ if message_date:
+ print("Found date in envelope FROM header: %s" % env_from_date)
+ # Otherwise, look for a Received: header we can scan
+ if not message_date:
+ for recv_from in msg.get_all('received', []): # We may have multiple of these, not all have "from".
+ m = re.match(r"from[^;]+?;\s+(.+?)(?:$|[\r\n])", recv_from)
+ if m:
+ message_date = email.utils.parsedate_tz(m.group(1))
+ if message_date:
+ print("Found date in Received header: %s" % m.group(1))
+ break
+ if not message_date:
+ print("Could not find any valid dates in email headers, using current time")
+ epoch = time.time()
Review comment:
A time of some sort must be used. The present time makes most sense as a default, as that would work for archiving in real-time. For importing, there really isn't a proper value either way. Both epoch 0 and current would be equally "wrong".
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] sebbASF commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
sebbASF commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711608292
##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
message_date = email.utils.parsedate_tz(
str(msg_metadata.get("archived-at"))
)
-
if not message_date:
- epoch = time.time()
+ print("No message date could be derived from the Date: header, looking elsewhere.")
+ # See if we have a "From" header line in the raw email, we can use
+ first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+ if first_line.startswith("From "):
+ # If we have one, the date must be the third element when splitting by single space.
+ env_from_date = first_line.split(" ", 2)[-1] # Split twice, grab last element.
+ message_date = email.utils.parsedate_tz(env_from_date)
+ if message_date:
Review comment:
What about parse errors?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] sebbASF commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
sebbASF commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711609467
##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
message_date = email.utils.parsedate_tz(
str(msg_metadata.get("archived-at"))
)
-
if not message_date:
- epoch = time.time()
+ print("No message date could be derived from the Date: header, looking elsewhere.")
+ # See if we have a "From" header line in the raw email, we can use
+ first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+ if first_line.startswith("From "):
+ # If we have one, the date must be the third element when splitting by single space.
+ env_from_date = first_line.split(" ", 2)[-1] # Split twice, grab last element.
+ message_date = email.utils.parsedate_tz(env_from_date)
+ if message_date:
+ print("Found date in envelope FROM header: %s" % env_from_date)
+ # Otherwise, look for a Received: header we can scan
+ if not message_date:
+ for recv_from in msg.get_all('received', []): # We may have multiple of these, not all have "from".
+ m = re.match(r"from[^;]+?;\s+(.+?)(?:$|[\r\n])", recv_from)
+ if m:
+ message_date = email.utils.parsedate_tz(m.group(1))
+ if message_date:
+ print("Found date in Received header: %s" % m.group(1))
+ break
+ if not message_date:
+ print("Could not find any valid dates in email headers, using current time")
+ epoch = time.time()
Review comment:
For importing maybe there should be a option to skip the message; it may make sense to allow the user to correct the data - especially since they can add a suitable From time without needing to change the message content.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] Humbedooh commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
Humbedooh commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711608540
##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
message_date = email.utils.parsedate_tz(
str(msg_metadata.get("archived-at"))
)
-
if not message_date:
- epoch = time.time()
+ print("No message date could be derived from the Date: header, looking elsewhere.")
+ # See if we have a "From" header line in the raw email, we can use
+ first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+ if first_line.startswith("From "):
+ # If we have one, the date must be the third element when splitting by single space.
+ env_from_date = first_line.split(" ", 2)[-1] # Split twice, grab last element.
+ message_date = email.utils.parsedate_tz(env_from_date)
+ if message_date:
Review comment:
if the date cannot be parsed, the function returns None. it does not raise an exception.
If that's not what you asked about, I'd appreciate some context
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] sebbASF commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
sebbASF commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711609273
##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
message_date = email.utils.parsedate_tz(
str(msg_metadata.get("archived-at"))
)
-
if not message_date:
- epoch = time.time()
+ print("No message date could be derived from the Date: header, looking elsewhere.")
+ # See if we have a "From" header line in the raw email, we can use
+ first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+ if first_line.startswith("From "):
+ # If we have one, the date must be the third element when splitting by single space.
+ env_from_date = first_line.split(" ", 2)[-1] # Split twice, grab last element.
+ message_date = email.utils.parsedate_tz(env_from_date)
+ if message_date:
+ print("Found date in envelope FROM header: %s" % env_from_date)
+ # Otherwise, look for a Received: header we can scan
+ if not message_date:
+ for recv_from in msg.get_all('received', []): # We may have multiple of these, not all have "from".
+ m = re.match(r"from[^;]+?;\s+(.+?)(?:$|[\r\n])", recv_from)
+ if m:
+ message_date = email.utils.parsedate_tz(m.group(1))
+ if message_date:
+ print("Found date in Received header: %s" % m.group(1))
+ break
+ if not message_date:
+ print("Could not find any valid dates in email headers, using current time")
+ epoch = time.time()
Review comment:
For archiving, I agree that current time is OK.
For importing, I think it would be better to use a value that does not vary between imports.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-ponymail-foal] Humbedooh commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid
Posted by GitBox <gi...@apache.org>.
Humbedooh commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711608977
##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
message_date = email.utils.parsedate_tz(
str(msg_metadata.get("archived-at"))
)
-
if not message_date:
- epoch = time.time()
+ print("No message date could be derived from the Date: header, looking elsewhere.")
+ # See if we have a "From" header line in the raw email, we can use
+ first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+ if first_line.startswith("From "):
+ # If we have one, the date must be the third element when splitting by single space.
+ env_from_date = first_line.split(" ", 2)[-1] # Split twice, grab last element.
+ message_date = email.utils.parsedate_tz(env_from_date)
+ if message_date:
+ print("Found date in envelope FROM header: %s" % env_from_date)
+ # Otherwise, look for a Received: header we can scan
+ if not message_date:
+ for recv_from in msg.get_all('received', []): # We may have multiple of these, not all have "from".
+ m = re.match(r"from[^;]+?;\s+(.+?)(?:$|[\r\n])", recv_from)
+ if m:
+ message_date = email.utils.parsedate_tz(m.group(1))
+ if message_date:
+ print("Found date in Received header: %s" % m.group(1))
+ break
+ if not message_date:
+ print("Could not find any valid dates in email headers, using current time")
+ epoch = time.time()
+ else:
+ epoch = email.utils.mktime_tz(message_date)
notes.append(["BADDATE: Email date missing or invalid, setting to %u" % epoch])
- print(
Review comment:
Do you mean the invalid date? We can _try_, but it might just not exist at all. The most common error is the date header is missing altogether.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org