Email for LAN of things

This is somewhat of an admission of failure. You can't easily pigeon-hole everything, and most real projects use commercial software, homebrew, and hardware all at once. So, for you makers out there (including me) - this is where to put whole projects that don't fit well in the other forums.

Email for LAN of things

Postby Doug Coulter » Tue Feb 27, 2018 2:23 pm

Whether I'm here or on the go (assuming I had email access while mobile, which I don't since I'm cheap and don't need it) - it'd be nice if my lan of things could notify me of this or that - I may not want to keep all those web pages open and check them, I'd rather get a ping if something goes wrong perhaps.
Well, tried and true, hoary old email can get that done, and things like a raspberry pi can send email in an automated fashion, at least to a gmail account...so here's how.
Basically, I did what's described at this link: https://stackoverflow.com/questions/383 ... mtp-server
with only a slight twist. Since pi's can't easily do this (automated, of course if they can run chrome they can do it manually) with the full security dance, you need to turn off some of the security on *a* gmail account. Since I didn't want to do that on my main one, I just created another one just for this, and made it insecure as the directions above indicate you should do. I then set up the "idiot" account to forward mails to my real one - securely. This way, if the idiot account gets hacked, I can just disable it, and replace it with another, without disturbing my main one or ruining its security.
Not that hard..
I did find out while testing forwarding that sending mail from my main account to the new dummy one to be forwarded back doesn't fly - google is smarter than that...it seems to know you already know what you sent yourself. However, mail from any other source (including the new dummy but also any other source) does get forwarded to the main gmail account, nice! So you can set that up to notify, make a noise, or just keep that one tab open (new mail shows in the tab).

So here's my copy of the directions, because we all know links can be fragile:
automail.txt
text instructions
(2.23 KiB) Downloaded 18 times


The idea is that now some software running on the pi can send me email about any dodgy thing going on - for instance, that something in the security system triggered (motion detector and video record) or that I'm running low on water, whatever. And I'll be sure to get it, versus having to check the relevant web page emitted by that raspberry pi.

/////////////////////// Edit:
Slightly off-topic but related. I use this same "cutout" technique for online financial transfers -
I created a special bank account at my local bank. It has a zero minimum balance, and most importantly has NO bounce/overdraft protection. I don't keep much money in it, maybe $20 for fudge.
When I want to do an order online that wants a card #, I use the debit card for this account. About 10 seconds before I click "place your order" I transfer money from one of my "real" bank accounts into this cutout one - just the amount of the order I'm about to place. "In theory" the money is only there for a few seconds at a time, and the fact that there's a long track record of transfers with an attached note with the vendor name and the exact amount goes a long way towards solving any mistakes or fraud situations. If a banker pulls up the records, it's real obvious what is normal activity. If someone hacks my card - the most they can ever really get is ~$20, and I pay a bounce fee - once. The amusing thing is that since I started doing this, I've not been hacked, while before I was had twice - it's almost as though there's a way for those miscreants to know whether there's money in the account - in this case, usually, nope. Whatever, this works.

This has served me well, obviously. It did take awhile at first to convince my bank to turn off overdraft protection - eg the permission they assume to pull funds from other accounts (and also charge a bounce fee anyway! What a racket!) - but it's a small town and I'm not the only one who's been had with online cards - so now they "get it" and in fact my banker does this himself...
Just a suggestion. I hear there are other ways to accomplish the same thing, virtual or prepaid cards and whatnot. I find this way, which predates all those and is fast and easy with online banking, at least as good and certainly more convenient as I use it over and over.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3056
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Email for LAN of things

Postby Doug Coulter » Tue Feb 27, 2018 10:07 pm

Of course, things being what they are and perl's motto being "there's more than one way to do it", well, here's another way in perl.
Code: Select all
#!/usr/bin/perl
use Modern::Perl;
use Email::Send;
# need synaptic to install ssleay libs for below
use Email::Send::Gmail;

use Email::Simple::Creator;

my $mailaddr = 'dougtest53@gmail.com';
my $mailpwd = 'nope, not gonna say';

# google rejects this address due to security settings
#my $mailaddr = 'dcfusor@gmail.com';
#my $mailpwd = 'not telling you this';



  my $email = Email::Simple->create(
      header => [
          From    => $mailaddr,
          To      => 'dcfusor@gmail.com',
          Subject => 'Server down',
      ],
      body => 'The server is down. Oh shit. from dougtest53',
  );

  my $sender = Email::Send->new(
      {   mailer      => 'Gmail',
          mailer_args => [
              username => $mailaddr,
              password => $mailpwd,
          ]
      }
  );
  eval { $sender->send($email) };
  die "Error sending email: $@" if $@;

say "made it";


This is one of several ways I found when looking at the problem and probably isn't yet the best way. This still requires reduced security on the gmail acount used to send mail to wherever, despite having all sorts of crypto involved. I'm not sure if that's just google being google and rejecting apps that aren't some way white-listed, or what. I see there are some other ways, and I do want to get this right and remove the need for a dumb extra account to forward to the one I really look at (to be disposed of in case of breach).
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3056
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA


Return to Combined projects

Who is online

Users browsing this forum: No registered users and 2 guests