

- #SEND MAIL USING MAIL COMMAND IN LINUX HOW TO#
- #SEND MAIL USING MAIL COMMAND IN LINUX INSTALL#
- #SEND MAIL USING MAIL COMMAND IN LINUX UPDATE#
- #SEND MAIL USING MAIL COMMAND IN LINUX PASSWORD#
You can also send message from text files with the following command. We use -s option for subject line and -A option for attachment. $ echo "Message Body Here" | mail -s "Subject Here" -A attachment.zip Replace message body, subject, user email and attachment file name as per your requirement. Once it is installed, you can easily send emails with the following command.
#SEND MAIL USING MAIL COMMAND IN LINUX INSTALL#
You can install it with the following commands. Mail is one of the most common commands to send emails in Linux. Here are different commands to send email with attachment in Linux.
#SEND MAIL USING MAIL COMMAND IN LINUX HOW TO#
How to Send Email With Attachment in Linux In this article, we will look at how to send email with attachment in Linux. There are numerous tools in Linux to help you send emails. If you have other methods that enable users to send email, do not hesitate to mention them in the comments section.Did you know that you can send emails from Linux command line interface? Sometimes you may need to send email to others, as a part of system administration. You have seen how to use sSmtp to send one-liner emails as well as how to attach a file using mpack. Sending emails from the command line can be useful when you need a shell script to send emails manually and automatically. Read: How to display Images in the command line in Linux/Ubuntu Conclusion : Mpack -s “your text” /your/file/path/here you receive this error then you may want to refer to the previous section. In order to send an attachment file, you would first to install mpack: Now try again to send the email from your terminal and this time it will go though. Once you enable the change above, gmail will then allow access to less secure apps. Once you have done this, you will get a notification (probably by phone if not by email).

This security setting can be modified through the following link: You would have also received a notification from gmail related to this. The error above is mostly likely due to you not having allowed access to less secure apps on your gmail account. Printf “your text” | ssmtp like me, you get the error shown below : To do this, run the command below :Įcho “your text” | ssmtp send email command Read: How to tweet from the Linux Command Line Sending an email
#SEND MAIL USING MAIL COMMAND IN LINUX PASSWORD#
Make sure to assign the right permissions to this file since it contains your password or otherwise you may want to create a new email gmail for the sole purpose of sending emails from the terminal. In order to configure SSMTP, edit the /etc/ssmtp/nf in your preferred text editor and insert the following lines mailhub=:465 FromLineOverride=YES AuthPass=your_password UseTLS=YES Now issue the command below to install the SMTP client.
#SEND MAIL USING MAIL COMMAND IN LINUX UPDATE#
This is to update your repository index of packages.

Open up your terminal in order to Install ssmtp using the commands below: It is a client program that forwards your mail to the vendor’s SMTP server which reroutes it to the recipient’s email vendor before sending it to the recipient. SSMTP is a simple and lightweight MTA (mail transfer agent) that is used to deliver mails from a machine to a mail hub (that is, SMTP server). Gmail for example uses as their smtp server in order to allow users to access their Email service from other clients. Every time you send an email using for instance Gmail, Yahoo and the like, this protocol or service is invoked. The Simple Mail Transfer Protocol (SMTP) is a protocol used to send and receive emails. What is sSMTP?īefore introducing sSMTP, let’s first mention the SMTP protocol. For instance you would want to build an application which sends Emails … You will also be able to attach files to the Email. But why on earth would we want to send Emails from the terminal ? Well there could be many reasons. In this short tutorial, you will learn how to send one-liner emails using sSMTP from your Linux Ubuntu/Debian terminal.
