How to create a script in Ubuntu 14.04 to send an email with attachment?

Posted on 2015-02-02
Last Modified: 2015-06-29
I would like to create a script in Ubuntu14.04 to send an email, in an Exchange 2010 environment.   I want to double click on the file and then activate the script to send an email and attach a file it find on the desktop.
Question by:100questions
  • 4
  • 3

Expert Comment

by:R. Toby Richards
ID: 40584726
echo "This is the message body" | mutt -s "subject of message"  -a "/path/to/" --

Open in new window

You may have to install mutt. On Ubuntu, "sudo apt-get install mutt" worked fine for me. You may or may not need an SMTP server installed. My box has Sendmail, so I wasn't able to test it without having Sendmail.
LVL 11

Accepted Solution

Tej Pratap Shukla ~Dexter earned 500 total points
ID: 40585473
Try mutt - a terminal-based e-mail client for Unix-like systems.

To install mutt: -

# apt-get install mutt

Syntax of sending Email using mutt is given below: -

echo "Message Body"mutt  -s "Subject of Mail" -a <path of  attachment file> -c <email address of CC>  mail address of recipient

here s defines the subject of the mail and represents the recipients address

for further reference visit:


Author Comment

ID: 40594138
Thanks. Will Mutt work with Exchange 2010?

Expert Comment

by:R. Toby Richards
ID: 40594166
Yes, as long as the SMTP port (tcp/25) on the Exhange server is available to the Linux computer.
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.


Author Comment

ID: 40615077
On what version of Ubuntu will this work on?

Expert Comment

by:R. Toby Richards
ID: 40615081
Any version. Mutt is older than Ubuntu. It is older than Linux for that matter.

Author Comment

ID: 40857259
I have not tried this, no need for this at this time.

Author Closing Comment

ID: 40857260
Thanks.  Unsure if this works, as currently I am not in need of this any longer.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
change time in cron 4 65
Kali Linux store / persist wireless password 3 48
SSH connect to Amazon Centos Instance 7 40
Need BIOS update Linux for MSI X99A motherboard. 4 30
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now