Mail command in linux with attachment
- Mail command in linux with attachment how to#
- Mail command in linux with attachment install#
- Mail command in linux with attachment software#
In order to forward messages, you need an SMTP server configured. The reason for this is that we didn't provide mailhub settings at all. and, oops: sendmail: Cannot open mailhub:25. Here the "hello" string piped to the sendmail command will be the subject of the sent message, while the defined email address is naturally the recipient of the email. Type the below code in the terminal: echo "Subject: hello" | sendmail should send out the email if everything works correctly.
Mail command in linux with attachment install#
That can be done with SSMTP: sudo apt install ssmtpĪfter the installation completed, you can check if sendmail is able to forward messages. As mentioned before, the configurations are much simpler for sendmail when you abstract away the complexity of the configuration. Installing Sendmail Command Line Mailer PackageĪs the terminal output suggested, we need to run the Advanced Package Manager's install command - usually with root permission - to install the necessary package. After we add the SSMTP package, this command and the ssmtp command will both work and change the command prompt in the terminal. In this example, I tried if the sendmail command works. The program 'sendmail' can be found in the following packages:
Mail command in linux with attachment how to#
If the package is NOT installed, you'll receive a warning message and a suggestion how to install it: If the package is installed, the command runs, and the prompt changes - while trying to execute the command - and you'll see a blinking cursor followed by the message Recipient names must be specified in the case of sendmail. Type in the mailer package's name just the way you would run the command, to check if it's available: Check if Command Line Mailer Package is Installed SSMTP contains the sendmail package under the hood as you'll see and it facilitates the configuration, which is pretty hard for sendmail otherwise. I'll continue with sendmail and the SSMTP package. However, you definitely need one of them for email delivery. Either I'm unlucky or the others were wrong, but I had to install one manually. In most cases, either sendmail or postfix is available in each Linux distribution out-of-the-box or at least that's what similar blog posts say.
Mail command in linux with attachment software#
Please note that these pieces of software may be installed by other default package managers such as yum or dnf depending on your Linux system distribution.
I'll show you how to install the necessary console mailer packages and provide background for command line options based on the package's manuals.Īll the mailer packages throughout the tutorial are available through Debian's Advanced Package Manager so the installation steps in the example below may be used for all the showcased packages.
We'll look at custom configurations and touch on how to set up SMTP connections to email accounts or email service providers. In this post, you'll find examples of how to send email from the terminal. Whether you are a developer working non-stop in the Linux command line or a server administrator wanting logs or other data extracted from administered systems, knowing how to send email from the command line is greatly useful.