• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

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

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.
0
100questions
Asked:
100questions
  • 4
  • 3
1 Solution
 
R. Toby RichardsCommented:
echo "This is the message body" | mutt -s "subject of message"  -a "/path/to/file.to.attach" -- recipient@domain.com

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.
0
 
Tej Pratap Shukla ~DexterCommented:
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 abc@xyz.com represents the recipients address

for further reference visit: http://www.tecmint.com/send-mail-from-command-line-using-mutt-command/

Thanks
Dexter
0
 
100questionsAuthor Commented:
Thanks. Will Mutt work with Exchange 2010?
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
R. Toby RichardsCommented:
Yes, as long as the SMTP port (tcp/25) on the Exhange server is available to the Linux computer.
0
 
100questionsAuthor Commented:
On what version of Ubuntu will this work on?
0
 
R. Toby RichardsCommented:
Any version. Mutt is older than Ubuntu. It is older than Linux for that matter.
0
 
100questionsAuthor Commented:
I have not tried this, no need for this at this time.
0
 
100questionsAuthor Commented:
Thanks.  Unsure if this works, as currently I am not in need of this any longer.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now