0

I want to make text bold and send that output using SMTP as mail.

Mail configuration is done properly and i am getting mail.

But i am getting a .bin file instead of the printed line.

Please help me with this.

This is my code to make the text bold

bold=$(tput bold)
normal=$(tput sgr0)

echo "this is ${bold}bold${normal} but this isn't" > test.txt

cat test.txt | mailx -vvv -r "xyz@hotmail.com" -S smtp="xx.xxx.xxx.xx" xyz@hotmail.com

this is bold(in bold) but this isn't".

This as a mail notification.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
Kaverappa KU
  • 87
  • 1
  • 7
  • SMTP does not know anything about bold text. `tput` is a program that checks the interactive terminal definition for the escape sequence to get bold characters **on the screen** of your terminal, mail uses a different approach (e.g. `` tags on html email) but SMTP is only the protocol used to transfer the email. – Luis Colorado Jul 09 '19 at 08:21

2 Answers2

2

tput is a command that uses terminfo(3) (or termcap(3), depending on the system) to get the escape sequence that your interactive terminal uses to produce bold characters on output. That is not applicable to an email message, as the terminal on the receiver probably will not be the same (mostly won't, as normally people read email with graphical tools, not text based terminals anymore)

There is no concept of bold text in email. There is in HTML or other document formats (e.g. RTF, Word doc, Word docx, etc.) So the bold text will not appear as such in most of the mail readers (many of the text readers will avoid the escape sequences coming in the message, so they don't garble the actual text display)

Is it so important to focus on some part of the message, can you mark it with something less device dependent *****>>>>like this<<<<*****?

If you insist to send your personal terminal escape sequences to indicate a bold text, that doesn't appear as bold anywhere else in the world, you'll receive a lot of complaints from people that get their screens garbled by your messages. Worse if those are to be automatically sent.

Luis Colorado
  • 10,974
  • 1
  • 16
  • 31
0

If you add escape sequences (like produced by tput bold) into a text and send that via mailx or similar, the mail program might figure out that the text you send is not pure ASCII and deduce that this is probably a binary file.

As a result, the file is sent as a binary part of the mail.

Alfe
  • 56,346
  • 20
  • 107
  • 159