How do I send a file as an email attachment using Linux command line?

后端 未结 26 2443
盖世英雄少女心
盖世英雄少女心 2020-11-22 04:39

I\'ve created a script that runs every night on my Linux server that uses mysqldump to back up each of my MySQL databases to .sql files and packages them togeth

相关标签:
26条回答
  • 2020-11-22 05:29

    From looking at man mailx, the mailx program does not have an option for attaching a file. You could use another program such as mutt.

    echo "This is the message body" | mutt -a file.to.attach -s "subject of message" recipient@domain.com
    

    Command line options for mutt can be shown with mutt -h.

    0 讨论(0)
  • 2020-11-22 05:30

    Or, failing mutt:

    gzip -c mysqldbbackup.sql | uuencode mysqldbbackup.sql.gz  | mail -s "MySQL DB" backup@email.com
    
    0 讨论(0)
提交回复
热议问题