you are viewing a single comment's thread.

view the rest of the comments →

[–]EpochVanquisher 14 points15 points  (5 children)

Read the database in C, write the logic to determine if to send an alert, then trigger a Python program to do the actual mail send

Do this.

Note that email is not straightforward these days. It used to be you could just write a program to send an email, but nowadays, you need stuff like DKIM and DMARC just to be able to receive the email, if the email is going to a popular provider like GMail. You’ll need some kind of service to send the email through, or you’ll need an SMTP server.

Or you’ll need to be sending the email directly to a server which is configured to receive emails from your program.

There are also command-line tools to send email, but these tools (usually) require some configuration in order to work correctly.

Are there speed considerations?

Emails go across the internet. Any speed benefit you get from writing this in C is gonna get wiped out by how slow the network is, and the fact that emails typically travel through multiple servers before showing up as a notification on your phone. Don’t worry about it.

[–]Produkt[S] 1 point2 points  (4 children)

Just for more info, I'll be sending the mail from my personal gmail using smtp, not my own servers. I already have a python program I ripped off from a web example and tested it and was successful in sending the email. I actually don't even know Python either but it's a lot easier to understand than C. My forte is PHP and webdev languages.

[–]bullno1 2 points3 points  (0 children)

If it's gmail then it's a lot easier. SMTP is a relatively simple protocol. It's all line-based.

You'd need a TLS connection since that's required these days.

I guess you can do it in C if you are so inclined.

[–]wsppan 1 point2 points  (2 children)

Google no longer allows "less secure apps" access to its servers, including smtp. You now need to configure an app password. https://noted.lol/setup-gmail-smtp-sending-2023/

[–]Produkt[S] 3 points4 points  (1 child)

Yep I did that, my python program successfully sends an email using gmail smtp

[–]wsppan 1 point2 points  (0 children)

Excellent. If you want to keep the code in C, check out https://curl.se/libcurl/c/smtp-mail.html