Linux is a fun thing to use, as you can get pretty much everything going within a few lines of a code. No need to download applications from the mysterious pages. Without losing time, a laptop can find it on its own, which is kind of amazing for me.

Without a further ado, let me explain how to send an email from the Terminal command line.

I’m using 32-bit Ubuntu 17.10 ( codename: artful) if something doesn’t work quite as you planned from my tutorial you are either missing a library or your version is a bit different.

Not all versions are the same, especially because I am using older 32bit, and most of the people I know already have 64bit versions.

And usually when there is a version for 32 there is one for 64.

But, I am ok, I also had WinXP, the world didn’t end and I was writing quite comfortably with it. I also have a dumbphone and it is the best piece of communication junk I ever owned.

For me, the smartphone is a mini-computer that you can carry around and it is simply there to steal your family time.

The Terminal is the best thing ever because it spends less space and resources than a separate GUI interface, and it is very quick.

What is GUI? – It is a graphical user interface. That is simply said an application, a window or a box that you can see to use on your device.

I am extremely grateful because I can do all things I like from one frame only, I don’t need to open a few which can be pretty annoying.

For the email sending, you can install of course a ‘real’ application, at least the one that is visible, that you are used to having and the kind of an application that you can open from the Start Menu. So, if you dislike my idea of Terminal email, you can use for example the Geary.

Geary is an email application, and inbox for your mail. It is quite easy to download and install.

Open your Terminal and type this.

sudo apt-get install geary

And.. you have it. Open the program, verify your email and you will start to receive the emails in a usual way for the desktop email program.

But, if you want something more exotic, you would want to use the Terminal.

Now, you could use the Mutt, but it will stop working within a few days of the activity. I used only my Gmail on this Mutt program, because my other mail apps do not allow any POP/IMAP integration. I guess there is a way to do it, but there is also an easier way, so why to bother.

I will make a tutorial on Mutt some other time, now I will only explain some basics.

So, let’s send an email.

First, you will need a program, of course.

So, open the Terminal and start typing.

sudo apt-get install mailutil

sudo apt-get install ssmtp

sudo vim /etc/ssmtp/ssmtp.conf

—> now hit ‘i’

Find the line ( use Up and Down arrows) that says

> FromLine Override=YES

… and delete little brackets ( # )

Add these lines, or fill them up with necessary information.

> [email protected]

AuthPass=yourpassword ( you can use application specific password as well)

mailhub=smtp.gmail.com:587

Use STARTTLS=YES

Click on ESC and when you get an extra line below with ‘:’ write ‘wq’ press Enter and a program will exit.

Now, you have all set, and you can send emails.

Just one warning! Fireproof your main account ( online Gmail) with a Google OAuth or/and a phone, and you will be secure.

You can also use an n application specific password for your desktop installation ( of any kind, not just this) and install some sort of a program to defend you from all malicious attempts. If you are using this for shits and giggles, you don’t need all that, carry on.

Now, you are out, the screen is empty, how do you send an email?

Let’s try this.

echo “text of a message” | mail -s “Title of your message” [email protected]

Alt Gr ( right alt) + W = |

Ok, but you want to style a message in the file and then send it because it will be a long message.

Let’s do everything without leaving the Terminal.

Do not send a million emails, you will get blocked and blacklisted by Google, this is the same email box you usually use but the only difference is that you don’t see an application window.

First, you will need a place where you will keep your mail texts.

This command will create a directory or a folder where you will keep your message files.

mkdir Mail

Now, go inside of that directory, or a folder.

cd mail

Then you need to make a text file to write that message.

This command will create a file.

touch message.txt

Then you need to write something but you don’t want to leave your Terminal. This is usually me. I hate opening too many tabs and windows.

cat > message.txt

Now, write whatever you have and then press CTRL+D.

Take a look what you did in nano editor, add things if you need. You can also take a look at it with vim, vi or open it in the message folder.

nano message.txt

Ok, you have all that set, now let’s send it. If you are only testing, use your spare email till you learn how to do things properly.

mail -s “title of your message” [email protected] < /home/yourusername/Mail/message.txt

This command will send your message with a body of a message written in the text file message.txt to the [email protected]

If you want to send to the multiple recipients, you have to specify it.

a=”[email protected], [email protected], [email protected]

mail -s “title of your message” $a < /home/yourusername/Mail/message.txt

I still like to send emails one by one, but if you need for any reason to send a message to a group, that is an easy and fast way.

Also, everything you send in this way will be visible in your email online account as well, so you can’t miss anything, you can always check this.

I really enjoyed making this simple, basic tutorial for you, I hope you will put it into a good use and spare your time.

11 votes, average: 5.00 out of 511 votes, average: 5.00 out of 511 votes, average: 5.00 out of 511 votes, average: 5.00 out of 511 votes, average: 5.00 out of 5 (11 votes, average: 5.00 out of 5)
You need to be a registered member to rate this.
(1273 total tokens earned)
Loading...

Responses