Solved

mailx issue

Posted on 2015-01-08
9
117 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
linux pull logs and export FTP 4 71
nagios monitor 3 56
error log using ftp 7 41
What is linux 4.8.22? Is it the same as ubuntu 16.10 ?? 2 41
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

831 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