How to send HTML email using linux command line

前端 未结 11 2095
无人共我
无人共我 2020-11-28 04:29

I need to send email with html format. I have only linux command line and command \"mail\".

Currently have used:

echo \"To: address@example.com\" >         


        
11条回答
  •  旧时难觅i
    2020-11-28 04:54

    The problem is that when redirecting a file into 'mail' like that, it's used for the message body only. Any headers you embed in the file will go into the body instead.

    Try:

    mail --append="Content-type: text/html" -s "Built notification" address@example.com < /var/www/report.csv
    

    --append lets you add arbitrary headers to the mail, which is where you should specify the content-type and content-disposition. There's no need to embed the To and Subject headers in your file, or specify them with --append, since you're implicitly setting them on the command line already (-s is the subject, and address@example.com automatically becomes the To).

提交回复
热议问题