Linux - extract information from email and write to file

1

Using bash mailx or any other programs, would be a way to extract information from an email box and to write the specific information to a file?

Anyone has a clue about this, I have bunch of emails with tracking notifications every day, I would like to extract just the order no and the tracking no, and later to put that information to a FTP, but my problem is how can i extract that kind of information from an email box?

Svan

Posted 2017-02-10T09:57:33.483

Reputation: 11

What format of your mailbox? Is it maildir or mailbox(aka Mbox) ? – Alex – 2017-02-10T10:22:04.823

Hi Alex, maildir I believe. – Svan – 2017-02-10T11:50:08.457

Please note that https://superuser.com is not a free script/code writing service. If you tell us what you have tried so far (include the scripts/code you are already using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?.

– DavidPostill – 2017-02-10T12:05:46.113

@Svan you can use munpack or ripmime to extract content from maildir files but parsing it I think it would be a challenge because ebay inconsistent with email format they are sending, it could be a plain text but recently they sending emails as html with links to tracking number that has also has embedded codes for user tracking which are a random – Alex – 2017-02-10T12:18:27.613

If you receive tracking notification email regularly, use procmail to filter and process mail when it arrives. You can use formail to manipulate header/body of a single mail. I'm not to familiar with maildir, but if it's just a file for each message, use find etc. to go through all files.

– dirkt – 2017-02-10T13:36:06.327

@dirkt Maildir format is kinda obfuscated, like this =09=09=09=09=09=09Shipping service : USPS Retail Ground, so body of message might be extracted first to parse it in convenient way – Alex – 2017-02-12T22:53:14.817

No answers