LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-06-2013, 02:30 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
Sending mail from command line.


Dear all,
I would like to learn how to be able to send me mails from the command line.

I have read a bit this guide:

http://www.simplehelp.net/2008/12/01...-command-line/

and it when I try
something like that

mail -s “Hello world” you@youremailid.com < textToSend.txt
the command line returns back, which means that the line is executed. but I do not receive any mails.

I am not sure what is causing that . perhaps send mail is not installed . Please try to help me with the next steps but it should be a solution that will not interfere with my normal mails or make my system vulnerable to the outside world. I just need the mail for sending mails to my account.

Regards
Alex
 
Old 03-06-2013, 02:33 AM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Try:
Code:
~$ mailx -s “Hello world” someone@example.sample.com  < infile.txt
 
Old 03-06-2013, 02:34 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Well, if you got no error or msgs, it probably sent it to your mail server service on the same box.
What is your MTA/SMTP server; probably sendmail or postfix I'd guess.
Check /var/log/maillog; also try
Code:
mailq -AC
mailq -Lq
 
Old 03-06-2013, 02:53 AM   #4
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Original Poster
Rep: Reputation: 45
Houston we have a problem
Code:
 mailq -AC
postqueue: fatal: Queue report unavailable - mail system is down
user@host:~> mailq -Lq
postqueue: fatal: Queue report unavailable - mail system is down
 
Old 03-06-2013, 06:54 AM   #5
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
The 'mailutils' is installed successfully or not?
Try on terminal
Code:
$ echo "mail-body" | mail -s "mail-subject" "receivers.address@linuxmail.com"
If it is sent and received successfully then you can try above command mentioned by shivaa

If you still get this error.
Uninstall and install postfix and try again.
 
Old 03-06-2013, 08:52 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by pavi_kanetkar View Post
The 'mailutils' is installed successfully or not?
Try on terminal
"$ echo "mail-body" | mail -s "mail-subject" "receivers.address@linuxmail.com"" If it is sent and received successfully then you can try above command mentioned by shivaa
Wrong. The mailutils are obviously installed, since the command RUNS, and the OP mentioned he was getting output in the log files. Mailx will ALSO fail, since it appears that a mail system hasn't be set up.
Quote:
If you still get this error. Uninstall and install postfix and try again.
Wrong. Postfix is only ONE mail system, and it may or may not even be in use, so giving advice before knowing what the OP has is counterproductive.


OP, in order for your system to send mail anywhere, you have to configure the mail system, and start it. It appears you haven't, or that the mail system you have is down. Are you using postfix or sendmail?? You can start them with either "/etc/init.d/postfix restart" or "/etc/init.d/sendmail restart". That will stop any running processes for those services, and start them back up again, and may correct your "mail system is down" problem.

Mailx *CAN* work without either of those, but it also needs configuration, in order to know which other mail server to send your message TO. If you're in a company environment, chances are you already have a mail server. So, configure your mail system to use it as a smart host...there are MANY guides to do this for both postfix or sendmail.
http://www.cyberciti.biz/faq/configu...-a-smart-host/
http://gopalthorve.com/install-postf...ure-smarthost/

The man page on the mailx command will tell you how to use either another IMAP or POP3 server to send your mail through:
http://linux.die.net/man/1/mailx

Last edited by TB0ne; 03-06-2013 at 08:53 AM.
 
Old 03-07-2013, 01:51 AM   #7
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Sorry but no intention to put wrong information.
Once I got the same error.I kept the solution in my linux notes. I did following process and it was solved.
I was getting
Code:
mail postfix/postqueue[20397]: fatal: Queue report unavailable - mail system is down
When I installed the mailutils,the postfix was installed automatically. I did not install it.
I was not able to send mails using terminal or apache (php mail function)
I found it on one site to detect the error, it asked first what is the out put of
Code:
mailq -AC
same command (asked by chrism01)
It gave me
Code:
mail postfix/postqueue[20397]: fatal: Queue report unavailable - mail system is down
The solution was there, Uninstall and install postfix. I did the same and then I type
Code:
mailq -AC
Now this time it gave me
Code:
Mail queue is empty
and I was able to send mail using
Code:
$ echo "mail-body" | mail -s "mail-subject" "receivers.address@linuxmail.com"
It looks like the error is same so I gave this solution, i didn't mean any harm (to OP's system).

Last edited by fortran; 03-07-2013 at 01:52 AM.
 
Old 03-07-2013, 07:37 AM   #8
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Original Poster
Rep: Reputation: 45
Hi it was fixed by starting postfix. could you please let me know if I have to apply any specific security settings?

Regards
Alex
 
Old 03-07-2013, 09:15 AM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by alaios View Post
Hi it was fixed by starting postfix. could you please let me know if I have to apply any specific security settings?
There's no way we can answer that, since we don't know what the security requirements are of your organization, where the server is located (facing the internet? Internal only?), or what you're trying to do.
 
  


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
Command line sending of mail attachments ( DB backups) gamorgan Linux - Newbie 7 12-19-2010 03:16 AM
Command line e-mail and NOT sending out malware nelson202tx Linux - Newbie 2 10-16-2010 02:36 AM
Sending mail from command line Geert86 Linux - Server 10 11-30-2009 12:04 PM
Sending mail from command line matiasquestions Linux - Software 5 01-22-2006 11:51 AM
sending mail from command line won't work disorderly Linux - General 2 06-09-2005 11:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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