I have a cron job which produces a list of resource, expiration date and the days until expiration. The report produces a CSV file. I attach this to the a message using mutt -a report.csv
.
I also want to include information in the body of the email. I use gawk to format this into clean lines and add this to the body. It looks something like this:
Resource Expiration Date Days
======================================== ========================= ========
resource one Oct 11 2009 07:59 PM 3
resource two Nov 3 2009 07:59 PM 22
resource three has a longer name Nov 6 2009 07:59 PM 28
rscrc 4 Dec 8 2009 07:59 PM 58
you get the point Dec 17 2009 07:59 PM 66
www.blockbuster1.smartsubs.net Dec 23 2009 07:59 PM 70
(yes, I fudged the dates and expiration, they don't add up in this example)
The problem is that most of the recipients do not have their email clients configured to show plain text email using a fixed width font. So, for them, it looks like this:
Resource Expiration Date Days
======================================== ========================= ========resource one Oct 11 2009 07:59 PM 3
resource two Nov 3 2009 07:59 PM 22
resource three has a longer name Nov 6 2009 07:59 PM 28
rscrc 4 Dec 8 2009 07:59 PM 58
you get the point Dec 17 2009 07:59 PM 66
www.blockbuster1.smartsubs.net Dec 23 2009 07:59 PM 70
Are there suggestions for how to easily format this text in email so that is forced into a fixed width font? I have flexibility to install new command line tools on this server
If you have a sufficiently recent version of mutt I believe you can do something like this.
index.html will be the html body of your message.
I would say just build an html table using print statements, hacky but works, I have done it before.
Less hacky, would be to use a csv to html table converters. Here is one with awk. You can then just send both html and plaintext, and their reader should use. You will have to look up how to do that with whatever mail library/program you are using.
Either way, I would go with the tables over trying to force the fix width font. I think the table would be more consistent (I don't have any actual evidence of that though).
Couldn't you wrap the whole thing with a p element and an inline style set for a monospaced font and preformatted spacing?