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

后端 未结 8 2260
旧巷少年郎
旧巷少年郎 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:31

    If I understand you correctly, you want to send mail in HTML format using linux sendmail command. This code is working on Unix. Please give it a try.

    echo "From: me@xyz.com
    To: them@xyz.com
    MIME-Version: 1.0
    Content-Type: multipart/alternative;
    boundary='PAA08673.1018277622/server.xyz.com'
    Subject: Test HTML e-mail.
    
    This is a MIME-encapsulated message
    
    --PAA08673.1018277622/server.xyz.com
    Content-Type: text/html
    
    <html> 
    <head>
    <title>HTML E-mail</title>
    </head>
    <body>
    <a href='http://www.google.com'>Click Here</a>
    </body>
    </html>
    --PAA08673.1018277622/server.xyz.com
    " | sendmail -t
    

    For the sendmail configuration details, please refer to this link. Hope this helps.

    0 讨论(0)
  • 2020-12-13 10:31

    -a option?

    Cf. man page:

    -a file
              Attach the given file to the message.
    

    Result:

    Content-Type: text/html: No such file or directory
    
    0 讨论(0)
提交回复
热议问题