Sending HTML mail using a shell script

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

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

13条回答
  •  [愿得一人]
    2020-11-28 04:33

    The tags include 'sendmail' so here's a solution using that:

    (
    echo "From: me@xyz.com "
    echo "To: them@xyz.com "
    echo "MIME-Version: 1.0"
    echo "Content-Type: multipart/alternative; " 
    echo ' boundary="some.unique.value.ABC123/server.xyz.com"' 
    echo "Subject: Test HTML e-mail." 
    echo "" 
    echo "This is a MIME-encapsulated message" 
    echo "" 
    echo "--some.unique.value.ABC123/server.xyz.com" 
    echo "Content-Type: text/html" 
    echo "" 
    echo " 
    
    HTML E-mail
    
    
    Click Here
    
    "
    echo "------some.unique.value.ABC123/server.xyz.com--"
    ) | sendmail -t
    

    A wrapper for sendmail can make this job easier, for example, mutt:

    mutt -e 'set content_type="text/html"' me@mydomain.com -s "subject" <  message.html
    

提交回复
热议问题