Linux Send Email From Console

www.lautt‮moc.iru‬
Linux Send Email From Console

To send an email from the Linux command line, you can use the mail command. This command allows you to send a message to one or more recipients.

Here is the basic syntax for sending an email using mail:

mail -s subject recipient@example.com

Replace "subject" with the subject of your email, and "recipient@example.com" with the email address of the person you want to send the email to.

After running the command, you will be prompted to enter the body of your email. When you are finished, press CTRL+D to send the email.

If you want to send the email to multiple recipients, you can list their email addresses separated by a comma:

mail -s subject recipient1@example.com,recipient2@example.com

By default, mail uses the local mail server to send the email. If you want to specify a different mail server, you can use the -S option followed by the server's address:

mail -S smtp.example.com -s subject recipient@example.com

You can also specify additional options, such as the email address to use as the sender, or attach a file to the email using the -a option. For a full list of options, you can use the man command to view the mail manual page:

man mail

Keep in mind that the mail command is not installed by default on all Linux distributions. If you do not have mail installed, you can use another command-line email client, such as mutt, or use a script to send email using a programming language like Python or Bash.

Created Time:2017-10-30 10:17:38  Author:lautturi