Solved

mailx issue

Posted on 2015-01-08
9
113 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
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 76

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 76

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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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 76

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now