Sending Emails? Send them from Linux Terminal | Linux Journal

Does your job require you to send a lot of emails on a daily basis? and you often wonder if you can or how you can send emails from the linux terminal.

This article explains 6 different ways to send email using the linux terminal. let’s go over them.

send mail command

Use the sendmail command to send email to one or more people at a time. sendmail is one of the most popular smtp servers on linux. you can easily send email directly from the command line using the sendmail command. to route information, the sendmail command makes use of the network configured on your system.

let’s run the following commands to create a file with email content.

the subject will be the line used as the subject for the email.

now to send the email, use the following syntax.

mail command

Like sendmail, you can use the mail command to send email from the terminal. use the command given below for this purpose.

here -s defines the subject of the email.

To send an attachment included in the email, type the line mentioned below.

here -a is used to include attachments. if yours is a debian-based distribution, use -a because it uses the mailutils package.

If you have to send emails to multiple recipients at once, add emails separated by commas as follows.

mailx command

gnu mailutils is a combination of several utility packages. all mailutils can operate on mailboxes from unix maildrops, maildir and even remote mailboxes. these mailboxes are accessed with imap4, pop3 and smtp. mailutils is made for developers, regular linux users, and system administrators.

See Also:  How to write a mail to hr for asking for job

For installation purposes, use the following command.

the mailutils package is mainly made up of 2 commands, mail and mailx, and they both work in a similar way.

above is the syntax that mail/mailx understands. this includes the address to send the message to, a suitable subject line, and some body text. Using the echo command and sending the output to the mail command allows you to avoid the mailx prompts for cc and the body of the text message.

swaks command

The swaks command is a flexible, transaction-oriented, programmable smtp tool. smtp extensions and features handled by this command are authentication, tls, pipelining and other versions of smtp protocols. this linux command also supports various transport methods, such as unix domain sockets, internet domain sockets, and units for spawned processes.

To install this tool, type:

you need to connect to an smtp account: the user -au, the server -s, the address -t and the password -ap. you also need the -tls flag in case you are connecting on port 587. so the command should be:

ssmtp command

you can send email using smtp server from linux terminal using ssmtp.

use the lines mentioned below to send emails with ssmtp.

here we are sending an email to the user [email protected]. you need to add a subject with the keyword “subject”. then you will write the message you want to convey to the recipient of the email. at the end of your message press ctrl+d (^d) to send the email.

See Also:  How to Buy a Postal Van or Truck | It Still Runs

mute command

mutt command helps to send and read emails from your linux terminal using local users mailboxes. furthermore, it can read emails using pop/imap servers. mutt looks like the mail command. to send emails, use the following syntax.

you can send an email containing an attachment using the mutt command to do so, use the command as follows.

the conclusion

You have learned how to send email using the linux terminal. now you can send email directly from the terminal without having to worry. Practice the methods given here to make it easy for you to send email from the command line.

Leave a Reply

Your email address will not be published. Required fields are marked *