How can I send properly formatted emails from the command line?

0
5
Asked By CuriousCat42 On

I'm trying to send an email from my machine that includes a small table, specifically a 2x4 table. However, I'm having trouble keeping the formatting intact when using the command line. I attempted to format the text using `column -t file.txt | sendmail`, but the email doesn't retain the layout as expected. I also got some advice suggesting that I should use `mailx` and send HTML files, but then I end up receiving the HTML code in raw format instead. I'm really looking for help with this; any tips would be appreciated!

4 Answers

Answered By OldSchoolCoder On

Honestly, I recommend not sending HTML at all. Instead, focus on creating a clean text file using a proper text editor. Terminals generally use monospaced fonts, which makes it easier to maintain the formatting you want.

Answered By TechieTom On

Instead of trying to fight the formatting issue, have you considered just using your regular email client? It might be way simpler for what you want to achieve.

Answered By FormatWizard On

Make sure the table looks correct on your sending machine. Sometimes formatting issues happen because of hard tabs—it’s better to use soft tabs (like spaces) for consistent alignment.

Answered By HelpfulHank On

To get HTML emails working, you'll probably need to modify your email's header to specify that the content type is 'text/html'. If you try sending HTML as plain text, you'll just get the raw HTML instead of a nicely formatted email. I haven't used `mailx` myself, but that might lead you in the right direction!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.