Line breaks in mail spool

Hi,

I have an issue with the line breaks in the mail spool- /var/mail/user1. I have set up a script to go through the mail spool on one of the users and parse some parts of the mail, however there doesn't seem to exist the regular line endings CR, LF or both in the lines and this is breaking my script. The mails are sent from a java application to a POP3 account on exchange 2013 server and then I pull them with fetchmail and use postfix on the local server as MDA.
Actually the issue comes from the fact that there is 78 characters line wrapping of the plain text mail body, which breaks the lines and cannot grep correctly- I then tried to remove the line breaks with sed, but since I cannot find the new line character that is used I cannot replace it with sed. Any ideas on on how to find what new line char is used or how to remove the line wrapping from the body would be much appreciated.

a sample/representative block of data and the desired output would help. Of course using the code tags...

Hi,

Below is the data sample. The first line ends with the equal sign, so I need to remove the equal sign together with the EOL character. Generally when I view this mail in Outlook it looks fine and the line is displayed as without breaks.

The workflow with ID "TestJob-xxxxxxxxxxxxxxx" finished with status "FINISH=
ED_ERROR" on Site "Site-1".
The components finished with the following statuses:
StandardComponents-Import: FINISHED_ERROR

Not sure I fully understand the problem, but for removing the undesired line break try

sed '/=\r*$/ {N;s/=\r*\n//}' file
The workflow with ID "TestJob-xxxxxxxxxxxxxxx" finished with status "FINISHED_ERROR" on Site "Site-1".
.
.
.
1 Like

Hi RudiC,

That's exactly what I was looking for. Thank you very much.