LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-18-2016, 07:13 AM   #1
roni.baby
LQ Newbie
 
Registered: Jan 2016
Posts: 4

Rep: Reputation: Disabled
mail attachment not sending from servers using mail command


As part of SSH monitoring in our servers, I have created a bash script and put it in my /etc/profile.d/ directory. So I can see that this script executed with every SSH login and I am able to get the detail of the user, who is logged in and from which IP etc using it.
Actually I am getting this mail with content as a message body. I wanted to get this as a text file attached
I am writing these details in /tmp/ssh_monitoring.txt using this script

I used the following mail command to achieve it but I am not success

" | mail -s "`whoami` has just logged on `uname -a | awk '{ name = $2 } END { print name }'`" "${EMAIL_RECEPIENTS}" -a /tmp/ssh_monitoring.txt

It will be good to get the support of this issues

Roni
 
Old 04-20-2016, 03:04 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Quote:
Actually I am getting this mail with content as a message body. I wanted to get this as a text file attached
You may try mutt instead of mail:
Code:
echo "Message body" | mutt -s "Subject" -a "/path/to/some/file" -- user@domain.com
Regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I m new to Linux ,need help to send mail with attachment via mail command Rhel 5.3 panks1910 Linux - Newbie 1 12-14-2012 12:56 PM
Sending mail attachment via Sendmail antanas Linux - Newbie 6 11-25-2009 05:54 PM
sending mail in php to Israel mail servers Four Programming 4 10-23-2009 10:37 AM
can mail command be used to send mail onto global mail servers like yahoo etc dale_chip Linux - Newbie 4 08-12-2008 08:33 AM
Postfix mail transfer agent not sending mail locally or to other servers sketelsen Linux - Software 3 02-09-2006 11:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration