Solved

mailx issue

Posted on 2015-01-08
9
121 Views
Last Modified: 2015-01-09
Hi All
    i use mailx to send email, now, i run echo "test send" | mailx -s "biaoti" 1324514@qq.com on my linux, i can get the email, but when i run mailx -s "test from shell" 1324514@qq.com, it will stopping, please see an attachment, i can only ctrl+C to cancel it. i would like to use mailx to send a file to my email, how can i do?
mailx-issue.jpg
0
Comment
Question by:beardog1113
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 78

Expert Comment

by:arnold
ID: 40539477
In your first attempt
Test send is the message this is the echo "test send"


On your second attempt, mailx tells you ok, what is the message. When done hit ctrl-D to indicate you are done with the message, EOF.
0
 
LVL 78

Expert Comment

by:arnold
ID: 40539484
Mailx is an email client.

If you detail what it is you are trying to and in what context you want email messages sent, there might be suggestion to better and straight forward to send out messages from scripts or based certain parameters when met.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 40539485
In your second attempt, you are killing mailx rather than giving it some text.


Add your text, then either do:

ctrl-D

or a dot followed by a blank line.
0
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
LVL 23

Expert Comment

by:savone
ID: 40539519
As stated above you need to tell mailx what the message is.  You can do this using redirection, or echo and I am sure there are other ways.

Using redirection:

mail -s "TEST MESSAGE" 1324514@qq.com < /path/to/textfile
0
 

Author Comment

by:beardog1113
ID: 40539522
[root@localhost ~]# mailx -s "Monitor Report att" -a /usr/local/nagios/var/nagios.log 1324514@q            q.com
EOT
Null message body; hope that's ok
[root@localhost ~]#

i have file nagios.log on my linux disk, i would like to use mailx to send this file to my email 1324514@qq.com, i run above command, after i press ctrl+D, is show me the message "Null message body"; hope that 's ok, and i can get the email. but if i do not press ctrl+D, seems the command will keeping running.
any idea?
0
 
LVL 23

Accepted Solution

by:
savone earned 500 total points
ID: 40539526
Yes, redirect the log file like so:

mailx -s "Monitor Report att" 1324514@qq.com < /usr/local/nagios/var/nagios.log
0
 
LVL 48

Expert Comment

by:Tintin
ID: 40539527
or do

echo | mailx -s "Monitor Report att" -a /usr/local/nagios/var/nagios.log 1324514@qq.com
0
 

Author Comment

by:beardog1113
ID: 40539529
mailx -s "KEER Server Monitor Report" -a /usr/local/nagios/var/nagios.log 1324514@qq.com < /usr/local/nagios/var/emailcontent.log

thank you i change the command as above, because i would like send nagios.log as an attachment not email contant, i also create new file emailcontent.log, write some text in the file like "please see an attachment". now my question is, the email content can not support Chinese, any idea?
0
 
LVL 78

Expert Comment

by:arnold
ID: 40539538
There are better email clients such as mutt and pine That can be sued on the command line and are more versatile.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question