8

cross-posted from: https://beehaw.org/post/10863052

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
top 4 comments
sorted by: hot top controversial new old
[-] Max_P@lemmy.max-p.me 16 points 7 months ago* (last edited 7 months ago)

You did. The only reason it didn't work is because you sent the email to your own computer but targetting a Gmail account. At best Exim relayed it to Gmail which promptly discarded it because you basically tried to spoof the mail as coming from Gmail. It failed every possible email security/validity checks: SPF, DKIM, DMARC, you failed all 3.

Your best bet to send an email with a shell script and telnet is to connect to Gmail's submission on port 587, authenticate then send the mail. Since it came in proper this time around, it'll be delivered correctly.

Or you can configure your exim server to do that properly for you so that you can just use sendmail from your script and let Exim deal with all the authentication and delivery.

[-] dis_honestfamiliar@lemmy.world 3 points 7 months ago

I think it can be done, but I don't remember the details. Are you able to configure ssmtp? Are you able to send email to any email address? Also, I think it only works with sstmp and not stmp maybe?

[-] codemonkey644@programming.dev 1 points 4 months ago

Would a service like ntfy.sh work for you? You send a curl request to an HTTP endpoint and subscribe to it, and it'll send you a push notification on your phone or web browser where you are also subscribed at. I've done this for remote system backup monitoring.

[-] ericjmorey@programming.dev 1 points 4 months ago

Ask on the original post, I'm not the person who is asking.

this post was submitted on 09 Jan 2024
8 points (72.2% liked)

Shell Scripting

1169 readers
1 users here now

From Ash, Bash and Csh to Xonsh, Ysh and Zsh; all shell languages are welcome here!

Rules:
  1. Follow Lemmy rules!
  2. Posts must relate to shell scripting. (See bottom of sidebar for more information.)
  3. Only make helpful replies to questions. This is not the place for low effort joke answers.
  4. No discussion about piracy or hacking.
  5. If you find a solution to your problem by other means, please take your time to write down the steps you used to solve your problem in the original post. You can potentially help others having the same problem!
  6. These rules will change as the community grows.

Keep posts about shell scripting! Here are some guidelines to help:


In general, if your submission text is primarily shell code, then it is welcome here!

founded 1 year ago
MODERATORS