Linux under the use of mail to solve

  


Computer shop news Today, when using mail to send mail to your own mailbox on the Linux server, there are various problems.

Because of the monitoring requirements, I wrote a simple script to send the information on the server to my mailbox. After the script is written, it will run first:

-bash: mail: command Not found

Later I remembered that the system was minimally installed, many of the toolkits were not installed, and then found that sendmail was not installed, so the yum installation was completed:

yum -y install Mailx sendmail

After waiting for the installation, run the script again, no error, but the mail is not sent out, check the server mail log found:

cat /var/log/maillog

Dec 17 11:42:29 localhost sendmail[30528]: qBH3gT5P030528: [email protected], ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, Mailer=relay, pri=30138, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]

The reason for this error Is /var/spool/mail this directory has insufficient permissions, you need to set it to 777

chmod -R 777 /var /spool/mail

Then restart the sendmail service

service sendmail restart

Call the script again, it works fine.


Copyright © Windows knowledge All Rights Reserved