• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2614
  • Last Modified:

Unable to send mail from Ubuntu server

I am setting up Nagios on an Ubuntu 8.10 server and am unable to get email notifications to work. I don't think Nagios is the problem since I cannot get the following simple line to send an email:

mail -s "Test Email" address@company.com
ctrl+c (twice)

where address@company.com is my real email address. I've tried sending to both an internal and an external address. I installed mailx prior to this testing and it installed successfully. In other posts, it said to troubleshoot by checking mail.log which I found in /etc/log but this file is empty. What else can I do to troubleshoot mail? Thanks.
0
Marc_Johnson
Asked:
Marc_Johnson
  • 13
  • 8
  • 6
2 Solutions
 
fosiul01Commented:
what mail server you using ??
0
 
Marc_JohnsonAuthor Commented:
You'll have to bear with me as I don't have any experience with mail in Linux. Are you saying that mailx that I installed is simply a email client and that I need to relay off of a smtp server? We are running MS Exchange 2003. If that is the case, how do I configure mail on the Ubuntu server to reference the SMTP service on Exchange?
0
 
fosiul01Commented:
maix is a command to sent email, but to send email from that server you need to install mailserver such as  sendmail or postfix or some other..

which one you have ??   [ if its sendmail then i would be able to helpfull , i dont have too much experience in postfix]

suppose if you install sendmail, then you would be able to either send email directly from your server, or by using smart host options to sent via exchange 2003 server  
0
Industry Leaders: 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!

 
Marc_JohnsonAuthor Commented:
I would rather just use the existing SMTP server in Exchange. What is the syntax for 'mail' in referencing another SMTP server?
0
 
fosiul01Commented:
sorry you cant

you will have to install some smtp software[sendmail or postfix] in your server to work with sending mail,

without installing anything it would not work
0
 
Marc_JohnsonAuthor Commented:
fosiul01,

I am a little confused. Can you help understand what the following clip in the Nagios documentation might mean with regard to email notification? I followed these instructions exactly. I appreciate your help. I assumed that this was all that was needed.
9) Other Modifications
If you want to receive email notifications for Nagios alerts, you need to install the mailx (Postfix)
package.
sudo apt-get install mailx
Youll have to edit the Nagios email notification commands found in
/usr/local/nagios/etc/objects/commands.cfg and change any /bin/mail references to /usr/bin/mail. Once
you do that youll need to restart Nagios to make the configuration changes live.
sudo /etc/init.d/nagios restart
Configuring email notifications is outside the scope of this documentation. Refer to your system
documentation, search the web, or look to the NagiosCommunity.org wiki for specific instructions on
configuring your Ubuntu system to send email messages to external addresses.

Open in new window

0
 
fosiul01Commented:
yes, its maix (postfix)

so you need to install postfix

mailx just a commmand which is mail -s

mailx use any mailserver programm to send email outside

without a mailserver programm mailx is useless

mailx also work with sendmail

if you have sendmail install
then mailx will use sendmail binaray to send email outside

have alook this one , the first command about  mailx with sendmail binary
http://forums.opensuse.org/archives/sf-archives/archives-software/344947-mailx.html

0
 
Maciej SsysadminCommented:
Although you got information, that mailx is required for email notification, it is not needed :)
However it's almost standard, so it's good to have it installed. You may use other application than mailx - you just need to redefine some commands in nagios to use your other MUA.
Anyway - you can use mailx and then you need also some SMTP server (it can be postfix, sendmail, qmail or anything you want).
You may also use mutt instead of mailx (in that case, you don't need SMTP server, as mutt is capable of sending with remote SMTP server), but you have to remember to change appropriate part of nagios configuration, and to configure mutt to use your Exchange.
0
 
fosiul01Commented:
I guess i explained cleared enough to the author that without installing sendmail or postfix or other mail client he would not be able to use mailx .

anyway, about mutt and nagois notification, its looks like people is having trouble to configure nagois notification with mutt
http://www.mail-archive.com/nagios-users@lists.sourceforge.net/msg06536.html

its 100% easy to configure nagois with mailx and which is recomended by nagios

and just make a simple mailserver such as sendmail its only take 5 minutes




0
 
Marc_JohnsonAuthor Commented:
I installed Postfix and chose "Satelite" which says to use a smart host for sending/receiving email. When prompted for the smart host, I put in the IP address of our Exchange server. But I still cannot send mail. What am I missing now?
0
 
Maciej SsysadminCommented:
I agree, that having SMTP on localhost is good idea (but it's not always required).
As for someone's problems with mutt with nagios - I didn't read all the posts from your link - just looked at the first one. I would rather use mutt it 'mailx compatibility mode' (-x option) and with proper configuration file (containing configuration for SMTP).
It's just another option to try.
0
 
Maciej SsysadminCommented:
Provide some messages from your mail log. Without this information we can only guess (and my guess is, that your exchange requires authentication, so you need to configure postfix in such way, that it authenticates with some username/password).
0
 
Marc_JohnsonAuthor Commented:
I looked at mail.log located under /var/log and there is only one line:

Feb 24 12:50:34 NAGIOS postfix/master[16842]: daemon started -- version 2.5.5, configuration /etc/postfix

which just tells me that the daemon started right after I installed Postfix. Any idea how I configure postfix with a username and password to authenticate to Exchange? If it is easier, I can forgo the whole relay thing. Like I mentioned, the only thing I need this box to do is to send Nagios notifications (and for that matter, the notifications just need to go to internal Exchange accounts). I'm all for simplicity at this point! I appreciate all of your input on this.
0
 
fosiul01Commented:
Hi
you dont have to use smart host to relay domain

by default postfix or sendmail would be able to send email

from your linux box

just type :  mail -s "Test Email" address@company.com

see if you get the email or not

it should deliver the email by using postfix itself without the relay


also : if you want to use exchange server as realy, you will see in exchange server there is an options call realy
just add the pc Ip in that realy box, this will allow realy from that linux pc
0
 
Maciej SsysadminCommented:
Try running this (from your NAGIOS host):
telnet localhost 25
ehlo localhost
mail from:<your_username@localhost>
rcpt to:<your_username@localhost>
data
test
.
quit

This is sending email to your local account.
After sending this, provide messages from mail log. If you get some messages in above telnet session, paste them here also.

Then, put here output of "postconf -n" command.
0
 
fosiul01Commented:
also
i am not that expert in postfix as i said earlier,

but in postfix there should be an option

/etc/postfix/main.cf

just edit relayhost = yourmailserver name

which could be exchange.yourdomain.com

then restart postfix
0
 
fosiul01Commented:
sorry about the command for sending mail from command line, i think there is a mistake for syntax

cat /etc/hosts | mail -s "test" youremailaddress

so it will sent an email to your email address with hosts file [ its just to test]
0
 
Marc_JohnsonAuthor Commented:
fosiul01,
The problem is that I installed Postfix with the relay option (because I didn't know what I was doing). How do I change it back to send mail without trying to use a relay? Also, I did make an exception on the Exchange server with the IP address of this Linux box.

oklit,
Can you clarify something with your smtp commands? Should I literally put the name localhost in or the actual name of my linux box (i.e. hostname)?
0
 
fosiul01Commented:
I think you have put smart host in here right

go to
/etc/postfix/
then
vi or nano main.cf

check in relayhost options , you must of put your exchange server address in their

just comment that line

and restart postfix, it should be allright
0
 
fosiul01Commented:
about @Oklits mailtest , you will see something like this


-bash-3.2# telnet localhost 25

Connected to localhost.
Escape character is '^]'.
220 mail.xxxxx.co.uk ESMTP Sendmail 8.13.8/8.13.8; Tue, 24 Feb 2009 21:39:41 GMT
mail from:root@localhost               -------------- need to type
250 2.1.0 root@localhost... Sender ok
rcpt to:xxxx@yourcompany.com                   -------------------- need to type
250 2.1.5 xxx@yourcompany... Recipient ok
data                            ---------------- need to tpe then press enter
354 Enter mail, end with "." on a line by itself
test        ---------------------- need to type then press enter
.             ------------------------ need to type then press enter  
250 2.0.0 n1OLdf0r004153 Message accepted for delivery
quit
221 2.0.0 mail.xxx.co.uk closing connection
Connection closed by foreign host.


or also you can try by sending from command prompt by mail -s command

0
 
Marc_JohnsonAuthor Commented:
Hmmm. I'm not sure what has changed but when I send with:

cat /etc/hosts | mail -s "test" youremailaddress

it works now to both internal and external email addresses. Sweet!

The emails say they are coming from root. Do you know how to change this label to something a little more user friendly?
0
 
Maciej SsysadminCommented:
Send it from some other account ;)
You may also try changing this with postfix canonical, but I would rather leave as it is.
0
 
fosiul01Commented:
ommmm i guess right now its comming from

root@localhost is not it ??

you can change it to root@postfixpc.com
or root@postfix

by changing

/etc/hosts file

change it to
your-pc-ip   postfix.com

or

your-pc-ip postfix

so now if you sent email it should come

root@postfix or root@postfix.com ( as you defined in hosts file)


0
 
Marc_JohnsonAuthor Commented:
fosiul01,

Thanks but I'm not going to worry about the from title for now. But I am curious. Any idea on why this started working? I never did remove the reference to our Exchange server (smart host) in main.cf.
0
 
fosiul01Commented:
hahaah
tough question, without seeing the log file its hard to say,

but i think it was fine from Before!!!


but for some reason this command does not work

mail -s "Test Email" address@company.com

its hangs ...
but cat /etc/hosts | mail -s "test" address@company.com
works

so just only  mail -s "test" address@company.com  does not work

it could be reason we were typing wrong command!!

and if its true then I am most stupid ....
0
 
Maciej SsysadminCommented:
"mail -s "Test Email" address@company.com" just waits for email's body.
type some text<Enter>
.<Enter>
and email will be sent (line with dot only ends email).
If you want to send empty email: mail -s "test email" address@company.com < /dev/null
0
 
fosiul01Commented:
hahaa LOL as i said, I am stupid

thanks Oklit to tell  me where i was doing wrong... for mail -s command ....

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 13
  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now