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 10-14-2010, 05:22 PM   #1
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Rep: Reputation: 40
getting To: from a file for sendmail or mailx?


Hi group,
I need to control sendmail or mailx from a file. The file will have the receprent as the first line, Subject: has the second line, etc. From what I can find with Google the only why to define the target and subject is on the command line?

Does any one know of a way to make a mailer use the data in a file??

The file would look like this:
Code:
me@mydomain.com
Testing
begin message
.
Thanks for you time.
 
Old 10-14-2010, 07:03 PM   #2
tc1280
LQ Newbie
 
Registered: Sep 2004
Location: GA
Posts: 3

Rep: Reputation: 0
getting To: from a file for sendmail or mailx?

From the command line you could use head -n 1 <file> for the address and sed -n 2p <file> to send your file from the command line
 
Old 10-14-2010, 08:58 PM   #3
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
Ah! Good point tc1280.

Assuming the file is named file,
the address is on line 1,
the subject is on line 2, and
the message body is line 3 to the end,
try this:
Code:
sed 1,2d file | mailx -s "$(sed -n 2p file)" "$(sed 1q file)"
 
  


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
sendmail mailx johnh10000 Linux - Server 9 02-27-2010 06:17 AM
[SOLVED] bash: how to redirect to file verbose output of mailx? val3xiv Linux - General 3 02-26-2009 07:02 PM
Cannot build sendmail.cf from sendmail.mc file simplified Linux - Server 5 11-01-2008 04:10 AM
Syntax using nail (mailx) for smtp without postfix or sendmail Casey Linux - Server 2 06-12-2007 01:41 AM
sendmail: I can't find the file sendmail.mc Ali79 Linux - Software 1 02-17-2005 12:25 PM

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

All times are GMT -5. The time now is 08:47 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