in reply to formated text

It works fine for me when run from cron. Formatting shouldn't depend on terminals at all. What is your code doing when run from cron, and what does it do when you run it from the command-line? What do you expect it to do?