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
Yes, you can. Though as another commenter mentioned, doing it like you currently attempted to, is way too much of a hassle.
That is, don't try and negotiate your own SMTP session and content. Being POP_OS is Ubuntu based, you should be able to use the
mail
command frommailutils
packageecho "Is this working?" | mail -s "Subject" recipient@email-address.org
Also might want to consider something like Apprise (Everything and the kitchen sink) or NTFY (Does one thing, does it well) for other types of notification methods.
This didn't work for me, but what I'm gathering from the other comments is I need an SMTP configuration on my machine before I can do this. Thanks so much for the help!
If you use gmail you can create an app password that can be used for this. Or if you have a domain you can e.g. use free tier zoho mail or something to create an email address.