
To view the last part of an email log, use the tail command line utility (by default tail without any option will give the last ten lines).Below are the various, well known methods of sending email with attachment from the terminal. If everything seems to be working okay, the next step is to check the email service logs found in the /var/log/maillog file. Some errors are easy to handle while others may require some sort of analysis.
The mail command in linux how to#
More details on these email commands and their respective flags are found on the “man page.” How to Troubleshoot Mail Problemsĭiagnosing email problems covers a broad range of services. Always make sure that you are reading from the correct user directory if your server hosts multiple domains.Īll these commands should get you started with sending emails from the Linux terminal and understand the basic knowledge of using executable shell scripts. The mail command reads all emails from the “var/mail/” directory. When you are entirely done press letter Z followed by the enter key to bring your back to the list of emails. When done reading, press on letter Q to load the previous screen. Key in the number that you want as listed on the screen above and press enter.
The mail command in linux install#
To install swaks in Debian/ Ubuntu Systems runĪt the end of the output is a question mark that prompts for your input in the form of a command. Very useful in handling SMTP features like the TLS and authentications. The swaks command is flexible, scriptable and a simple SMTP test utility. If no file name is issued you must use a trailing / after the last directory to indicate no file name was given. The command option -upload-file is used to transfer the specific file “mail.txt” to a remote URL. You can use this flag multiple times for different addresses. The –-mail-from flag specifies a single address that the issued email address should be used to send the mail, in this case it is The –-mail-rcpt flag denotes the recipient address, in our case, the mail will be delivered to. The command option requests the connection to be terminated if the server does not support a secure connection, i.e. When using the –-ssl-reqd flag you must ensure that the connection is running on SSL or TLS. txt - user above command uses the –-url –-user flags to define SMTP connection settings. To install mail command in Debian and Ubuntu Systems, run The two commands process messages on the command line. Mail is installed as part of mailutils and mailx packages on Debian and Redhat systems respectively. The Linux mail command in Linux/Unix is quite popular and is commonly used to send emails from the command line. -b for the blind copy email address (BCC).Some of the command line options taken by most mail commands are: The Common Mail Package Installations: Command The root user should is the only authorized user who can install these mail packages. It is also vital that you learn how to send Linux mail attachments. In this article, you will learn how to send and read emails using the popular commands and learn how to send mail using a shell script. When the need to send an email via the command line option, there are numerous ways to go about it. Some command line utilities can be used for convenience when manipulating applications from the somewhat unfriendly screen. You can use the shell to monitor processes, automate backups, and parse data. The mail command in linux/unix is a powerful tool once system administrators get to know their way around it. Let’s Learn mail Command in Linux/Unix with Practical Examples :
