EDIT: Thanks y’all! I got this working by installing mutt and configuring it with my Gmail info. Please note the warning from u/jherazob below–if this were something mission critical I would not want to rely on this solution.
================
Noob question incoming, thanks in advance for any help with this!
I have a specific use case in which I want to send an automated email or text to myself once a day (the message is different each time–otherwise I would just set an alarm, lol!). I’m running Pop_OS on an old desktop computer. Where I’m stuck is getting an email to successfully send from the command line. I’m looking for easy-to-follow instructions that would help me do that, and none of the articles or videos I’ve come across thus far have helped.
I’m aware of Twilio and other services that send SMS messages, but I’m looking for something free. Especially since I only need to text one person (myself), and infrequently at that.
Below is my attempt to send an email with the telnet command. Nothing ever came through…
XXXXXXXX@pop-os:~$ telnet localhost smtp
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 pop-os ESMTP Exim 4.95 Ubuntu Sun, 07 Jan 2024 15:12:28 -0500
HELO gmail.com
250 pop-os Hello localhost [::1]
mail from: XXXXXXXX@gmail.com
250 OK
rcpt to: XXXXXXXX@gmail.com
250 Accepted
data
354 Enter message, ending with "." on a line by itself
Subject: Test
Body: Is this working?
.
250 OK id=1rMZW4-0002dj-Uy
quit
If all you need is to send a notification from a script to your phone, I’d like to suggest https://ntfy.sh/
As somebody who has been there before, it’s 100% possible to use email for notifications and have that fully scriptable, but given how extremely stringent email providers have become over the decades and still getting tougher as we speak, i would very much recommend not depending on email for this. Ideally you’d have multiple channels in case one fails for the REALLY vital stuff, but at least you should have one that is not email. There’s many:
- One of the various ways to generate push notifications that have been mentioned in the thread
- Chat messages, people have mentioned using Telegram, Signal or others, and some of those have desktop version too
- Yes, email, but not as the only way, you don’t wanna stop receiving notifications because Google just decided your IP is spamming and is bouncing all your alerts
- One of the various cloud notification things like the AWS ones mentioned (pretty sure all the cloud providers have their own version)
- Something like a monitoring service or self-hosted server (I’ve used Zabbix in the past and like it, although this is FAR more involved)
- Text messages? This will depend on services on your area, here they’re so rare i never consider this option
- Others i can’t think about right now (need more coffee)
Whatever you do have in mind that ANY of these can fail, so if there’s anything truly critical be sure to both have a way to know if one notification system is failing, and to have a plan B to receive notifications/alerts even if one is down. Depends on how critical stuff is of course, for tests you don’t need triple redundancy or whatever, but for the service the company’s income depends on you don’t wanna have a system that stopped working and you never knew.
Any reason not to use something like Gotify and handle it as a notification instead?
Lots of valid suggestions already here. But I’ll throw one more to the pile. You could use the Pushbullet free plan (100 notifications per month). And then either use a python library or Google for a bash script to help with getting the notifications out. Then have Pushbullet installed on your phone.