Since the shell script was recently written in CentOS5.6 and the mail sending function was required, I found the mutt software. It is a text-interface-based email client that is very small but powerful. It can be used to read and write, reply, save, and delete your emails, it can send and receive email attachments in linux Command Line Mode. For more usage please refer to the official website: http://www.mutt.org www.2cto.com 1. mutt installation and installation of the operating system, general Linux will install mutt by default, CentOS is no exception. You can use which mutt to view the mutt installation path. If not, run yum install mutt on the command line to install mutt. The newer mutt version is. 4.2.2-3.0.2.el5 after mutt is installed, you can have a good manual under/usr/share/doc/mutt. 2. after the mutt configuration is installed, run the find command to find the file Muttrc. find/-name Muttrc and find the file at the location of/etc/Muttrc, instead of the/root /. muttrc file. In this case, I first configured the/etc/Muttrc file and copied it to/root to change the file name to. muttrc. In fact, it is found that some systems do not need to copy the. muttrc file to/root, or they can correctly send and receive emails. By default, mutt calls/usr/sbin/sendmail to send emails. You can also configure the following configuration for sending emails to the/etc/Muttrc file by using msmtp, I append the following configuration at the end of the file: www.2cto.com set from = youremail@inc.com set envelope_from = yes my_hdr From: youremail@inc.com my_hdr Reply-To: youremail@inc.com ignore headers * unignore headers from 3. run the ps-ef | grep sendmail command to check whether the sendmail service is enabled, if it is not started, run echo "test" |/usr/bin/mutt-s "email send at $ dd on the shell command line! "Youremail@inc.com soon you will receive an email from the root in your mailbox, paste mutt syntax mutt [-hnpRvxz] [-a <File>] [-B <address>] [-c <address>] [-f <email>] [-F <Configuration File>] [-H <email draft>] [-I <File>] [-m <type>] [-s <subject>] [email address] parameter: www.2cto.com-a <File> add an additional file to the email. -B <address> specifies the recipient address of the BCC copy. -C <address> specifies the recipient address of the copy. -F <email file> specifies the email file to be loaded. -F <Configuration File> specifies the setting file of the mutt program, instead of reading the preset. muttrc file. -H: displays help. -H <draft email> sends the specified draft email. -I <File> Insert the specified file into the email. -M <type> specifies the preset mail type. -N do not read the program cultivation file (/etc/Muttrc ). -P, after editing the email in mutt, does not want to send the email immediately, you can suspend sending the email. -R: open the mail file in read-only mode. -S <topic> specifies the subject of the email. -V displays the version information of mutt and the parameters given when the file was compiled. -X simulates the editing method of mailx. When the-z parameter is used together with the-f parameter, if the mail file does not contain the mail, the mutt is not started.
Author sharong