Nov 10, 2018

How to send mail from command line with external smtp server on Linux

The default mail command on the Linux terminal, uses the local SMTP server (MTA) on port 25 to transmit emails. However sometimes you may want to specify an external SMTP server to use for sending mails. You can use mailx command:


$ echo "This is the message body" | mailx -v -r "reply-address@i88.ca" -s "This is the subject" -S smtp="mail.i88.ca:587" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="sender@i88.ca" -S smtp-auth-password="password" -S ssl-verify=ignore receiver@i88.ca