A simple C++ program that can be run on boot or on network change to send local ip address of the system to a pre-defined email ID, eliminating the need to connect an external monitor, find the ip and then ssh into the device.
- cURL, Cmake and a C++ compiler is required for compiling the code
sudo apt install curl cmake make g++ -y
- Modify line 3, 4 and/or 5 of config.h as per your requirements. Note that instead of putting your gmail account password, insert an app password instead. Read more about it here. Entering your gmail password will throw an error.
- Navigate to the project directory and run the following commands to build:
mkdir build && cd build
cmake ..
make
- You'll now see an executable named
ip_mail
that can now be run as a startup application.
After running the commands, you will see the following output:
.
├── CMakeLists.txt
├── include
│ └── ip_mail
│ ├── config.h
│ ├── email.h
│ ├── network.h
│ └── time.h
├── LICENSE
├── README.md
└── src
├── email.cpp
├── main.cpp
├── network.cpp
└── time.cpp