Send email from bash in Linux

Bash script to send email through SMTP server

#!/bin/bash

# Install msmtp if it's not already installed
sudo apt-get install msmtp -y  

# Create a configuration file for msmtp with your SMTP server details
cat > ~/.msmtprc <<EOF
defaults
auth on
tls on
tls_starttls on
tls_certcheck off

account aws_ses
host email-smtp.eu-central-1.amazonaws.com
port 587
from FROM@EMAIL.COM
user USER
password PASSWORD

account default : aws_ses
EOF

# Set proper permissions for the configuration file
chmod 600 ~/.msmtprc

# Send an email using msmtp
printf "Subject: Test smtp ubuntu\n\nHello there from ubuntu." | msmtp -a aws_ses bkr@bustroker.com,bustroker@bustroker.com