E-mailing just got handy

But, what about emailing from the server?

Good news hackers, I got you!

Note :

  1. This is only one way mailing system. You can only send emails, and not receive from the other end.
  2. There are many such emailing services for systems, but I found this one the quickest way to get your set-up done.
  3. It can be very handy to send short code-snippets to your colleagues or quick messages to your loved ones, from a server itself.
  4. One of its primary use cases of ssmtp service is forwarding automated email (like system alerts) off your machine and to the admin email address for him to remain notified about system health.

Let’s Dive In

  1. Update and get youself the latest of all packages.
$ sudo apt-get update$ sudo apt-get upgrade
$ sudo apt-get install ssmtp
$ cd /etc/ssmtp/
$ sudo vim ssmtp.conf
root=sender@gmail.com
mailhub=smtp.gmail.com
AuthUser=sender@gmail.com
AuthPass=password
UseSTRTTLS=YES
FromLineOverride=YES
ssmtp.conf
allow access from gmail

Let’s send messages

1. The Quickest of all :

$ echo "Greetings from terminal" | sendmail receiver@gmail.com
email received at the other end

2. A bit descriptive :

$ sendmail receiver@gmail.com
Subject: Hello Boss
Wanted to tell you, the job's done!
Get the party ready.

3. Full explanatory email :

$ touch message
$ vim message
detailed email
$ sendmail -t < message
or
$ ssmtp -t < message

Troubleshooting

  1. With UseSTARTTLS=yes you can only set port to 587, and not to 465.
  2. Errors like authorization falied could be due to denied access to unsecure apps from gmail account. Refer final but most important step-4.
  3. Multi-Factor authentication doesn’t allow to to grant access to less secure apps. So remove the MFA from your account.
  4. Errors might occur due to parsing error in its To, From sections.

Hacks : my fav

  1. You can send emails with differThent usernames. The username in the email, is system username.

Kudos! Now you won’t have to switch back-and-forth the gmail for simple messaging. More importantly, you can configure your system to act smart, and alert you everytime it detects something fishy, like DoS attack, unauthorized login attempts, etc.

--

--

--

In love with open-source ❤️

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

SRE / DevOps / Kubernetes Weekly Collection#54(Week 6, 2021)

Docker 101: Volume & Bind Mounting

OOP Metaprogramming Series: AST Parsing in Kotlin

How To Read Technical Books Effectively

Book and glasses on a table

ASP.NET Core API with Entity Framework

What is DNS Vendor Lock-in and Why You Should Avoid It

CLOUD COMPUTING !!!

Data Science or Web Development in 2020? (Both are fun, Overview for WEB, part 1)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vishal Gorai

Vishal Gorai

In love with open-source ❤️

More from Medium

Air Jordan 35 OUTDOOR Performance Review

Why you should be a UX Researcher

CS373 Spring 2022: Sabeer Shahzad Week 12

CS373 Spring 2022: Matthew Kozlowski — Week 11