CENTOS uses MUTT to send emails. centosmutt
Sometimes we need to send emails on the Centos server, such as backing up the MySQL database and sending it to the specified mailbox. Here we will talk about how to send emails from the Centos shell command.
Check, install, and start sendmail
// Check ps-ef | grep sendmail // install yum install sendmail // start service sendmail start // start chkconfig -- level 2345 sendmail on
Check and install mutt
// Check whether mutt is installed. If mutt is installed,/usr/bin/mutt # which mutt will be returned. // install mutt # yum install mutt
Configure mutt
// Copy. muttrc # cp/etc/Muttrc/root/. muttrc for the root user
Configure mutt. The above two methods are modified in the same way.
# Set charset = "UTF-8" # customize the sender information set envelope_from = yes # This line does not exist by default, please manually add set use_from = yes set from = xxx.com@xx.comset realname = "Master Lee"
Test email sending
// Syntax mutt [-hnpRvxz] [-a <File>] [-B <address>] [-c <address>] [-f <email>] [- F <Configuration File>] [-H <email draft>] [-I <File>] [-m <type>] [-s <topic>] [email address]
Send
Mutt 1343652445@qq.com-s "test mutt"-a test.txt <test.txt echo "mail body" | mutt 1343652445@qq.com-s "xxxx"-a test.txt
If the email is sent incorrectly, view the log (/var/log/maillog)
This article