Sending HTML mail using a shell script

前端 未结 13 1445
死守一世寂寞
死守一世寂寞 2020-11-28 03:46

How can I send an HTML email using a shell script?

13条回答
  •  自闭症患者
    2020-11-28 04:29

    Mime header and from, to address also can be included in the html file it self.

    Command

    cat cpu_alert.html | /usr/lib/sendmail -t
    

    cpu_alert.html file sample.

    From: donotreply@example.com
    To: admin@example.com
    Subject: CPU utilization heigh
    Mime-Version: 1.0
    Content-Type: text/html
    
    

    Mail body will be here

    The mail body should start after one blank line from the header.

    Sample code available here: http://sugunan.net/git/slides/shell/cpu.php

提交回复
热议问题