Using mutt + msmtp as the linux Mail Client these days, the leaders asked me to deploy a script written by the Development Department, and sent the attachment generated by the script to his mailbox via email. Let's get started, because the mail command has been used to send emails, but this time it won't work. Because the attachment is required. Someone told me that the mail command can contain attachments, but I didn't find the relevant parameters. But I don't want to set up a mail server, because I am not busy. Www.2cto.com began to find a simple and effective command line client on the Internet. That is MUTT + MSMTP. I saw a lot of articles on the Internet and took a few articles to follow them. The results reported various problems. Let's take a look at the specific functions of each parameter! After some sorting, some useless parameters are removed and the test is successful. Now I will write down the specific operation steps below: My goal is actually very simple, that is, using MUTT and MSMTP to log on to the 163 mail server and send an email. Why do I have to log on to my 163 mailbox? I tested the release of QQ mail, yahoo Mail, and sina mail, and only 163 of them went through. I guess it was the relationship verified in the mailbox settings and I didn't want to study him any more. The following gives the specific steps first to apply for a free mailbox 163, the charges are free to download MSMTPwget http://nchc.dl.sourceforge.net/sourceforge/msmtp/msmtp-1.4.17.tar.bz2tar xvf msmtp-1.4.17.tar.bz2cd msmtp-1.4.17. /configure -- prefix =/usr/local/msmtpmakemake installcd/usr/local/msmtp/mkdir etc # You must create your own cd etc vim msmtprc # manual Configuration file account default host smtp.163.com # Your mail server port 25 from xman@163.com # from which mailbox to send auth login # Here if on is used, it will report "msmtp: cannot us E a secure authentication method "error tls offuser xman@163.com # mailbox Username password xmanufo # mailbox password, here is plain text, if you feel insecure, you can change the file to the 600 attribute logfile/var/log/mmlog to save and exit. A simple test of/usr/local/msmtp/bin/msmtp xman@163.com casually enter some content to end with ctrl + d. Then go to your mailbox to see if you have received the message. If an error is prompted, follow the error code to find the cause, you can also check the above log file and start to install MUTT. If it is CentOS, use yum directly. After yum install mutt is installed, manually create a configuration file for it, vim/etc/Muttrcset sendmail = "/usr/local/msmtp/bin/msmtp" # Your msmtp command path set use_from = yesset realname = "xman@163.com" set editor = "vim" just four simple lines, let's test it! Www.2cto.com echo "testmail" | mutt-s "test"-a/etc/hosts ufo@sina.com here-a refers to adding an attachment, if it is more than one attachment, then add a few more-a file name can also be like this mutt-s "test"-a/etc/hosts-a/etc/apple ufo@sina.com </tmp/imax.txt this the content of the/tmp/imax.txt file is used as the mail content. Okay, that's simple. an error is reported after the test is performed as follows: [root @ bogon report] # echo "fujian" | mutt-s "fujian_test"-a "/root/qingshell/report/8.8.8.xls" liuzhiqing@123.com cannot stat liuzhiqing@123.com: without that file or directory liuzhiqing@123.com: Unable to append the file and then solve, add a-B parameter, so send the attachment will be OK... echo "fujiian" | mutt-s "fujian_test"-a "/root/qingshell/report/8.8.8.8.xls"-B liuzhiqing@123.com