My file format is as below:
cat myfile.txt
Size of user01 is 1863 MB, it over than 100 MB
Size of user02 is 1863 MB, it over than 100 MB
Size of user03 is 815 MB, it over than 100 MB
But if I mail it to my mailbox,
cat ./myfile.txt | mail -s "This is test Mail" myemail@domain.com
the format will be as below:
Size of user01 is 1863 MB, it over than 100 MB Size of user02 is 1863 MB, it over than 100 MB Size of user03 is 815 MB, it over than 100 MB
How can I keep my original format when I send file content to my mailbox!?
您可以尝试使用内容类型为 html 的 mail 命令并使用 html pre标记来获取它。
echo "<pre>`cat myfile.txt`</pre>" | mail -a "Content-type: text/html" -s "This is test Mail" myemail@domain.com
The SMTP specification says that end-of-line in SMTP messages is
\r\n (return+newline)
where in Unix/Linux the end of line is
\n (newline)
Run the text though a tr
filter to convert all the \\n to \\r\\n -- or pipe it through unix2dos
which does the same thing, like;
cat ./myfile.txt | unix2dos | mail -s "This is test Mail" myemail@domain.com
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.