• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 355
  • 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 RichardsNetwork AdministratorCommented:
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 ~DexterServer AdministratorCommented:
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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
R. Toby RichardsNetwork AdministratorCommented:
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 RichardsNetwork AdministratorCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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