This python3 script allow you to send email from the terminal using a json file as configuration file and a .txt file as the subject for the mail.
Install required packages
cd send_email
$ pip install -r requirements.txt
Create the config.json file with your credentials . This configuration file is for gmail Change port and server for others smtp providers.
{
"email": "xxx@gmail.com",
"password": "xxxxxx",
"port": 587,
"server": "smtp.gmail.com"
}
Remove reading write to the config file for other user to protect your credential
$chmod 600 config.json
Create a text file with the subject:
echo "The message to be send" > subject.txt
Send the mail:
python3 sending.py receiver@gmail.com -c config.json -s subject.txt -a 'Attachement Of The Mail : SENDED USING PYTHON3'