[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - Extracting date and time from a mail header

Extracting date and time from a mail header

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Extracting date and time from a mail header

Postby muncher1 » Fri Jan 21, 2005 10:19 am

Needing help on what a script must state to extract the date and time from an incoming or downloaded email. I was thinking stripping line 1 of the email address and that would leave only the time stamp left, but felt there was a better way. Any suggestions or example of what the script must state?

Thx

Edit Eric: Moved to PocoScript
muncher1
Poco Tourist
 
Posts: 27
Joined: Sun Dec 19, 2004 2:23 pm

First step done...neding help to get the receivers info.

Postby muncher1 » Fri Jan 21, 2005 12:14 pm

Got the senders (From:) info. Now how to get the receivers date time stamp received info. is the next puzzle. Any help will be appreciated.

Code: Select all
{ Get the sender's email address and date time stamp
ReadHeader $from "from:" %message
ReadHeader $date "date:" %message
{
{ Get the receiver's email address and date time stamp
ReadHeader $To "To:" %message
{
{
:SHOW
{ show senders email address and the date time stamp sent
MessageBox $from
Messagebox $date

{ show receiver's email address
MessageBox $to
{
{  **  Need help here.  How to extract from the header the date time stamp (received) when the mail was received by my ISP. **
{
{ ** Future work in progress **
{Now lets compare the sent time stamp and received time stamp for difference in time
{
{need help with the part of script to extract receivers time stamp from header
Last edited by muncher1 on Fri Jan 21, 2005 1:08 pm, edited 1 time in total.
muncher1
Poco Tourist
 
Posts: 27
Joined: Sun Dec 19, 2004 2:23 pm

Postby Hogyt » Fri Jan 21, 2005 12:53 pm

I don't think there is a command called Extract. Do you mean like this?
Code: Select all
ReadHeader $date "date:" %message
ReadHeader $from "from:" %message
ReadHeader $to "to:" %message

ExtractEmail $from
GetLine $firstto 0 $to
ExtractEmail $firstto

Messagebox $date
MessageBox $from
Messagebox $firstto

Bear in mind that the to header can have more than one line so depending on what you're doing you could loop through each line and extract the to addresses separately.
Mat
Hogyt
Poco Enthusiast
 
Posts: 241
Joined: Thu Jul 29, 2004 11:22 am
Location: England

Postby muncher1 » Fri Jan 21, 2005 1:07 pm

Thx Mat,

Your correct, there isn't a extract command. I'll redo the code. I'm able to read the senders email address and time stamp. Also, can get the receivers email address, but haven't figure out how to extract or get the receivers time stamp.

The end result of what I'm trying to do is determine the time difference between the senders time stamp and the received time stamp at my ISP. If it's greater then four hours (way outside CDT) for US based mail then it is from overseas and I want trash it.
muncher1
Poco Tourist
 
Posts: 27
Joined: Sun Dec 19, 2004 2:23 pm

Postby Michael » Fri Jan 21, 2005 1:46 pm

I would suggest getting the length of the date header using the CharCount command and then looking at the 5th character from the end. If it is a "+" or a "-" then you can probably assume the last 4 characters represent a GMT offset.

You may have to extend this by looking for a closing parenthesis in the last position and if found stripping the textual representation of the time zone before processing.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby muncher1 » Fri Jan 21, 2005 2:07 pm

Michael,

Brilliant suggestion. I went through a header that was sent to me in my time zone and both the senders time and mine say "CDT" -0600.

Argh! I don't have any spam from overseas saved so I can't see what their offset is. It may be as simple as comparing the offsets or time difference based on greenwich mean time.

Never look forward to spam, now I can't wait to get one to verify the time zone offsets. LOL

Updated: Went and looked in the backup and found one from Hong Kong. Sent showed a +0800 and receipt showed 0600. It makes sense that whatever comes from overseas will have a sent time stamp hours ahead the received time stamp in the U.S.

Now how to write a script to use this info. Could be as easy as determining that if the offset in time is greater then 4 then trash it.

I don't know how to strip this stuff out of the header so will have to wait for help in writing the code.
muncher1
Poco Tourist
 
Posts: 27
Joined: Sun Dec 19, 2004 2:23 pm

Postby Michael » Sat Jan 22, 2005 4:24 am

I would suggest a slightly different approach, keep a list of acceptable time zones and then process the date headers against that. You might be able to do this without scripting, see this article in the unofficial FAQ.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 0 guests

cron