LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   sending mail via CLI (https://www.linuxquestions.org/questions/linux-newbie-8/sending-mail-via-cli-299458/)

RomanG 03-09-2005 12:36 AM

sending mail via CLI
 
hello all!
i need to send a mail (one text file) from command line using sendmail. and also i do not want sendmail to stop and ask me to type a recipient or smth. else. i think this would look like "cat somefile.txt > sendmail 'and some options (recipient at least) i don't know' " what options should i use?

drumvudu 03-09-2005 02:15 AM

If you just want to send text to someone from the shell just give a: mail -vs "subject" someone@someplace.com and hit enter.
then type your text. When you are finished, put a period by itself on the last line and hit enter. You will see it go through OR not.../peter

drumvudu 03-09-2005 02:18 AM

I just reread your post. I'm not sure if you mean that you need to send someone a file or just a message. If you want to send an entire file, see : man nail.

RomanG 03-09-2005 04:26 AM

sorry, i didn't find nail on my system..
and you are right, i need not to type text, but use a prepared text file for it.

drumvudu 03-09-2005 06:35 AM

Nail is a tiny program, why not just install it and save yourself allot of grief? If you give a 'man mail' does the manual page for mail or nail come up? /peter

wpn146 03-09-2005 11:33 AM

Re: sending mail via CLI
 
Quote:

Originally posted by RomanG
hello all!
i need to send a mail (one text file) from command line using sendmail. and also i do not want sendmail to stop and ask me to type a recipient or smth. else. i think this would look like "cat somefile.txt > sendmail 'and some options (recipient at least) i don't know' " what options should i use?

Try:
Code:

cat somefile.txt | mail -s "subject goes here" somename@somewhere.com
-- or --
Code:

mail -s "subject goes here" somename@somewhere.com < somefile.txt
Do not use "cat somefile.txt > sendmail" That will just create a file named "sendmail".

RomanG 03-09-2005 11:06 PM

Many thanks to you wpn146. You helped a lot.
* Sometimes Google can't help, because I even don't know, the way/direction to search in..
Thank you again.


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