LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-07-2008, 01:19 PM   #1
aatwell
Member
 
Registered: Apr 2007
Location: San Jose, CA
Posts: 31

Rep: Reputation: 15
sending mail without user input


I've been looking at apps like sendmail, mailx, mutt trying to find one that will let me send an email automatically. Sendmail is a daemon and mailx and mutt both require the body of the message to be typed by a user. What I really need is an app where I can type a message in the command line and have it send the message like this....

mailx -a user@mycompany.com -s "My Subject" -b "Message Body"


Any ideas ?
 
Old 08-07-2008, 01:24 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,632

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by aatwell View Post
I've been looking at apps like sendmail, mailx, mutt trying to find one that will let me send an email automatically. Sendmail is a daemon and mailx and mutt both require the body of the message to be typed by a user. What I really need is an app where I can type a message in the command line and have it send the message like this....

mailx -a user@mycompany.com -s "My Subject" -b "Message Body"


Any ideas ?
How about writing a simple shell-script that does exactly the command you specified above???
 
Old 08-07-2008, 01:27 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
/path/to/sendmail "some.user@some.domain" << EOF
From: Me <my.mail@my.domain>
To: Recipient <other.mail@my.domain>
Subject: test mail - $variable

`date "+%A %e %b %Y %T"` - report n. $number

`cat /path/to/file.txt`

Best regards,
Alex

EOF
Using sendmail you can use a shell "here document" and can include the output of any command, the content of a file and any other text. If you need to send attachment, I suggest uuenview, which uses sendmail as well:
Code:
/path/to/uuenview -m $email -f "$from" -s "$subject" -a $file << EOF
See $file in attachment.

Best regards,
Alex
EOF
Hope this helps.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail not sending to local user? Julix Linux - General 2 09-07-2007 04:42 PM
how do i prevent a user from sending mail onyangoliech Linux - Software 4 12-15-2006 11:24 AM
prevent user from sending mail in postfix onyangoliech Linux - Networking 1 12-14-2006 07:29 AM
Sending Mail via cron every hour without user input. cpope67 Linux - Software 1 10-25-2004 01:55 PM
Sending Greeting mail to new user ranjit001 Linux - Networking 1 01-02-2001 11:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:11 AM.

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