Embedding an image in an email using linux commands

前端 未结 6 672
醉话见心
醉话见心 2021-01-02 06:33

Is there a way to embed images into the body of an email using linux commands like mutt or sendmail?

I used this

mutt -e \         


        
6条回答
  •  死守一世寂寞
    2021-01-02 07:15

    For those looking to send emails with embedded images as part of the email using a bash script, I pieced this code together.

    The email is started with these line:

    EMAILBODY="echo \"Alarm went off! "
    EMAILATTACH=""
    

    Inside of a loop that defines each file to attach:

    EMAILATTACH=$EMAILATTACH" -a /home/xyz/"$ID"/"$Event"/"$Frame"-capture.jpg"
    EMAILBODY=$EMAILBODY"
    "

    After the loop, the email is completed with these lines:

    EMAILBODY=$EMAILBODY"\" | mutt -e \"set content_type=text/html\" -s \"House Alarm went off!\""
    EMAILSTRING=$EMAILBODY$EMAILATTACH" -- user@server.net"
    eval $EMAILSTRING
    

    My last hurdle is that when I receive this on my android phone (maybe the same on other browsers), it doesn't display the picture, only a small box (even after you have downloaded the attachments). It shows up fine in Outlook though.

提交回复
热议问题