Instructions on how to set up a script to send an email with your IP in Ubuntu
-
Move to the folder where we will set the scripts
cd /usr/local/bin
-
sudo apt-get update sudo apt-get install sendemail
-
Download the code from github
sudo git clone https://github.com/esdandreu/send-email-with-ip.git
-
Navigate to the repository
cd /usr/local/bin/send-email-with-ip/
-
Make the main script executable
sudo chmod a+xrw send-email-with-ip.sh
-
Create the
.env
file with your data: Open the file with your favourite editor. In my case it isneovim
which can be installed withsudo apt install neovim
and then runsudo vim .env
to open it the file. Once you are editing.env
, write:export EMAIL="[email protected]" export PASSWORD="password" export TO="[email protected]"
Make sure that the
EMAIL
you wrote allows less secure apps. -
Modify the cronjobs
crontab -e
Choose an editor in the command line and add a line with:
@reboot sleep 60; /usr/local/bin/send-email-with-ip/send-email-with-ip.sh
Now everything is set up. Reboot and check!