swaks is a command line SMTP testing tool available at
http://www.jetmore.org/john/code/swaks/
On Debian/Ubuntu, you can install it with the command
apt install swaks
if you just type swaks, it will ask for your email, then send a mail using MX Record to a specified email address.
To send email using a specific mail server
swaks --to user@example.com --server test-server.example.net
Deliver a standard test email, requiring CRAM-MD5 authentication as user me@example.com. An “X-Test” header will be added to the email body. The authentication password will be prompted for if it cannot be obtained from your .netrc file.
swaks --to user@example.com --from me@example.com --auth CRAM-MD5 --auth-user me@example.com --header-X-Test "test email"
Here is an example command that uses a remote SMTP server to send email. I used this on a backup bash script to send email alters after the backup was completed.
swaks --to serverok.in@gmail.com --from labs@serverok.in --server smtp1.serverok.in --auth-user labs@serverok.in --auth-password '7XwlzPnSmlsWsdbS' --body "This is a test message" --header 'Subject: Backup completed'