Jump to content

Recommended Posts

I'm writing a script to auto generate time sheets.  I have it parse my syslog file to determine what time my computer was turned on and then turned off, based on log entries, for the past two weeks, calculates hours worked then emails it to me.

 

I have all of that fancy stuff working fine.  My problem is that the text won't format correctly.  The report I'm generating consists of 2 blocks (one per week) at 5 lines per block.  There is a row label followed by information.  I have a single subroutine that takes an array and generates this line with the individual elements divided by tabs (\t).

 

When I run this script and dump the report to a web browser (and view the source) it is formatted correctly.  All the tabs line up like they should.  When I send this report to my outlook account, windows screws up the tabs and has it all over the place.  Is there some header info that I'm missing in the email that is causing this?

 

 

Link to comment
https://forums.phpfreaks.com/topic/101226-solved-cross-platform-text-formatting/
Share on other sites

as much as I didn't want to, I just ended up turning it into an HTML formated email message.

 

For future reference, in case someone is searching and stumbles on this, you can do this by adding some stuff to the headers like:

 


$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: .......";

mail($to,$subject,$message,$headers);

 

i left out the other stuff, but apparently the \r\n at the end of each header line is mandatory or windows won't like it.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.