Users who are accustomed to Windows systems may initially have a bad grasp of the Linux system, and many features may not be used very well. This article introduces a small application of Linux systems: Use mail to send Internet Mail under Linux. But before I introduce mail, let's take a look at the SendMail service.
The SendMail service on Red hat is typically started automatically. You can view the status of the SendMail service by using the following command:
Service SendMail Status
If the SendMail service is not started, you can start with the following command:
Service SendMail Start
"Note" Every time you modify the network configuration (such as modify IP, host name, etc.), you must restart the SendMail service, or send mail will fail.
The simplest form of syntax for sending Internet mail using mail commands is:
Mail username@address
The following is a simple example of sending a message:
Subjiect: Is the subject of the message
Below is the body of the message
"Note" Here cc: is the actual result of pressing the CTRL+D key, does not belong to the mail content
To check whether a message is sent successfully, you can use the following command:
Sendmail–bp
If the "/var/spool/mqueueisempty" message is displayed, the message is sent successfully. Open your own mailbox to see it!
If another error message is displayed, the message must be sent unsuccessfully. What do we do? You will normally need to restart the SendMail service.
This is the reason why I mention sendmail service.
If you want to use the contents of a text file as the content of an e-mail message, you can do so by using the following command:
Mail-s "Subject" username@address
Or
Catfilename|mail-s "Subject" username@address
Parameter-s indicates the subject of the message
For example:
Mail-s "Atestmailfile" xiaofan@126.com
The Mail command cannot send attachments, and if you are sending attachments, it is recommended that you install the RPM package for the Mutt mail client.
Use the-a parameter to specify the attachment, and the other parameters are similar to the Mail command:
For example:
Mutt-s "Testmutt"-a/root/testmailxiaofan@126.com
Mutt is a very powerful software.
Summarize:
I hope this article describes how you can use mail to send Internet mail in a Linux system that helps readers. More knowledge about Linux systems remains to be explored and studied by readers.