Solved

mailx issue

Posted on 2015-01-08
9
115 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 77

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 77

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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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 77

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
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.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

912 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