Which email provider for Bash automation (notifications)

lane17

New Member
Joined
Sep 23, 2019
Messages
8
Reaction score
0
Credits
114
Which email provider do you guys use/recommend for automation? For example in sendemail ?

Long story short, I've been using this test account (outlook) to simply send myself emails with notifications if something was happening on my personal server. Now microsoft (and earlier google) disallowed third party apps so using those emails is almost impossible for my simple tasks. Also at this point I can't add anything to the server's installation, so I can't use my own email server. So I was wondering if maybe you guys have used email providers that would allow simple user:password credentials without any fancy security that would work for my needs?

If you are interested, here's the email I recently got:




Update your sign-in technology before September 16th, 2024 to maintain email access.

The safety and security of your information is top priority for Microsoft. To help keep your account secure, Microsoft will no longer support the use of third-party email and calendar apps which ask you to sign in with only your Microsoft Account username and password. To keep you safe you will need to use a mail or calendar app which supports Microsoft’s modern authentication methods. If you do not act, your third-party email apps will no longer be able to access your Outlook.com, Hotmail or Live.com email address on September 16th.


What do you need to do?

If you are receiving this email, you are currently using an email or calendar app that uses a less secure authentication method to connect to your Outlook.com email account. You will need to upgrade your third-party mail and calendar app to a version which supports modern authentication methods.

Microsoft provides free versions of Outlook for your PC, Mac, iOS, and Android devices which can be easily downloaded and connect to your email account. Using an updated version of an Outlook application will ensure you are connecting in the most secure way.

How can you set up your Gmail, Apple Mail, or other third-party mail application?

Various non-Microsoft applications will have their own steps for connecting to your Outlook.com email account using modern authentication methods. See our help article - Modern Authentication Methods now needed to continue syncing Outlook Email in non-Microsoft email apps. However, you may need to contact the creators of those applications to provide you with instructions. In many cases, simply removing and re-adding your account with the latest version of that application will configure it to use modern authentication methods.
 


You don't need email server, depending on your distro you should have MTA already installed.
On Debian the default one is called exim4, run man exim4 for instructions on how to send email.
exim4 and various other MTA's are command line programs so it should work just fine for scripting.

If your question is where to send it, then that's trivial problem, which ever provider should work to receive email.
 
You don't need email server, depending on your distro you should have MTA already installed.
On Debian the default one is called exim4, run man exim4 for instructions on how to send email.
exim4 and various other MTA's are command line programs so it should work just fine for scripting.

If your question is where to send it, then that's trivial problem, which ever provider should work to receive email.
That's helpful: i personally wonder how you could send the output of commands via email, though
 
i personally wonder how you could send the output of commands via email, though
I've never used exim to send email, but here is a blog post with examples that looks OK:

TL;DR It boils down to:
Bash:
echo "Subject: hello" | sendmail -v [email protected] < mail.txt

Where sendmail is symlink to exim4 as per man exim

 
I've never used exim to send email, but here is a blog post with examples that looks OK:

TL;DR It boils down to:
Bash:
echo "Subject: hello" | sendmail -v [email protected] < mail.txt

Where sendmail is symlink to exim4 as per man exim

I would assume your system has to be set up as an email seever though?
 
I have a copy of this:
https://github.com/zehm/sendEmail

which I just tested on Tiny Core 15.0 / x86_64 and it still works (It's been a longish time since I used it).
It's a couple thousand lines of perl code that can use an external smtp server to send messages. (While I feel like this could probably be condensed down to a couple hundred lines of shell script, I haven't tackled that yet. I freakin hate perl.)

Note that the first line (the shebang) references the perl interpreter at /usr/bin/perl whereas perl5.tcz places it at /usr/local/bin/perl - it says right on the page referenced above that "you may need to edit the first line of the script accordingly".

You do have to have an smtp account to use for this, whether it's on your ISP's server or something of your own doesn't really matter (I'm using my web hosting provider's smtp server with one of my domain's email accounts).

Code:
tc@dolly:~$ # Body text in-line with -m option
tc@dolly:~$ sendEmail -f ${FROM_ADDR} -t ${TO_ADDR} -u "${SUBJECT}" -m "${BODY_TEXT}" -xu $SMTP_USER_NAME} -xp ${SMTP_PASSWORD -s "${SMTP_SERVER:PORT}"
Sep 19 13:06:51 dolly sendEmail[24247]: Email was sent successfully!
tc@dolly:~$
tc@dolly:~$
tc@dolly:~$ # body text on stdin
tc@dolly:~$ echo "test (stdin)" |sendEmail -f ${FROM_ADDR} -t ${TO_ADDR} -u "${SUBJECT}" -xu $SMTP_USER_NAME} -xp ${SMTP_PASSWORD -s "${SMTP_SERVER:PORT}"
Reading message body from STDIN because the '-m' option was not used.
If you are manually typing in a message:
  - First line must be received within 60 seconds.
  - End manual input with a CTRL-D on its own line.

Sep 19 13:10:49 dolly sendEmail[24542]: Message input complete.
Sep 19 13:10:50 dolly sendEmail[24542]: Email was sent successfully!
tc@dolly:~$

tc@dolly:~$
 
I would assume your system has to be set up as an email seever though?
IDK honestly, didn't test it and it never interested me much to study more about how MTA's and email servers work, but exim is on my terminal schedule list.
 
Hi, thank you guys, I appreciate all your replies.

I've tried some of your suggestions in the past and for one reason or another they didn't work. Either there was something missing on my installation or I couldn't configure it on that machine. Just so you know it's a very old machinery that I'm only using for very simple tasks. Exim would be the way to go, but in like a year time, when I go and visit that server in its location and put it all together again from the scratch :)

Without setting up my own SMTP server, I have to rely on external email providers like google or this other company, which is why I initially asked about email providers.
 


Members online


Top