How to send a html email with the bash command “sendmail”?

后端 未结 8 2261
旧巷少年郎
旧巷少年郎 2020-12-13 09:50

Anyone has a demo available?

Sendmail is said to be not scalable,but it\'s free,so I decided to use it first for now:)

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 10:17

    To follow up on the previous answer using mail :

    Often times one's html output is interpreted by the client mailer, which may not format things using a fixed-width font. Thus your nicely formatted ascii alignment gets all messed up. To send old-fashioned fixed-width the way the God intended, try this:

    { echo -e "
    "
    echo "Descriptive text here."
    shell_command_1_here
    another_shell_command
    cat <
    EOF } | mail -s "$(echo -e 'Your subject.\nContent-Type: text/html')" to.address@company.com

    You don't necessarily need the "Descriptive text here." line, but I have found that sometimes the first line may, depending on its contents, cause the mail program to interpret the rest of the file in ways you did not intend. Try the script with simple descriptive text first, before fine tuning the output in the way that you want.

提交回复
热议问题