LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-19-2011, 09:10 AM   #1
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
Cool [How to] send a mail from cmd...


Hi all


Probably an easy question for you guys but i'm trying to send a mail from my cmd for testing purposes.
I tried this: (found it somewhere on the internet)
Code:
# /bin/mail -s "test" jefke@uitdebroek.com
is this correct?

thanks
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 04-19-2011, 09:13 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,211

Rep: Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612
I believe the mail syntax is:

Code:
mail -s "subject" someone@test.com < file.txt
 
1 members found this post helpful.
Old 04-19-2011, 09:20 AM   #3
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
oke, thx, i tried it, but i don't get any mail...
how can i check this if he really did send the mail?
 
Old 04-19-2011, 09:23 AM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,211

Rep: Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612Reputation: 1612
Code:
tail -f /var/log/maillog
 
2 members found this post helpful.
Old 04-19-2011, 09:23 AM   #5
savona
Member
 
Registered: Mar 2011
Location: Bellmawr, NJ
Distribution: Red Hat / Fedora
Posts: 195

Rep: Reputation: 50
Quote:
Originally Posted by brownie_cookie View Post
oke, thx, i tried it, but i don't get any mail...
how can i check this if he really did send the mail?
tail -f /var/log/maillog

---------- Post added 04-19-11 at 09:24 AM ----------

Quote:
Originally Posted by szboardstretcher View Post
Code:
tail -f /var/log/maillog
Great minds think alike.
 
1 members found this post helpful.
Old 04-19-2011, 09:29 AM   #6
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
thx ^^

this is what i get:

Code:
Apr 19 15:24:09 host_name postfix/qmgr[3331]: 5DF951AD808B: from=<emailaddress>, size=648, nrcpt=1 (queue active)
Apr 19 15:24:09 host_name postfix/qmgr[3331]: 5DF951AD808B: to=<emailaddress>, relay=none, delay=0.01, delays=0.01/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to something.be[IP]: Connection timed out)
Apr 19 15:25:10 host_name postfix/pickup[25160]: 1EAE61AD808C: uid=100 from=<nagios>
Apr 19 15:25:10 host_name postfix/cleanup[7797]: 1EAE61AD808C: message-id=<20110419132510.1EAE61AD808C>
Apr 19 15:25:10 host_name postfix/qmgr[3331]: 1EAE61AD808C: from=<emailaddress>, size=648, nrcpt=1 (queue active)
Apr 19 15:25:10 host_name postfix/qmgr[3331]: 1EAE61AD808C: to=<emailaddress>, relay=none, delay=0.09, delays=0.05/0.03/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to something.be[IP]: Connection timed out)
Apr 19 15:26:10 host_name postfix/pickup[25160]: AC5611AD808D: uid=100 from=<nagios>
Apr 19 15:26:10 host_name postfix/cleanup[7797]: AC5611AD808D: message-id=<20110419132610.AC5611AD808D>
Apr 19 15:26:10 host_name postfix/qmgr[3331]: AC5611AD808D: from=<emailaddress>, size=648, nrcpt=1 (queue active)
Apr 19 15:26:10 host_name postfix/qmgr[3331]: AC5611AD808D: to=<emailaddress>, relay=none, delay=0.35, delays=0.33/0.02/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to something.be[IP]: Connection timed out)
 
Old 04-22-2011, 07:59 AM   #7
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
No takers?

Code:
Apr 19 15:24:09 host_name postfix/qmgr[3331]: 5DF951AD808B: from=<emailaddress>, size=648, nrcpt=1 (queue active)
Apr 19 15:24:09 host_name postfix/qmgr[3331]: 5DF951AD808B: to=<emailaddress>, relay=none, delay=0.01, delays=0.01/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to something.be[IP]: Connection timed out)
Apr 19 15:25:10 host_name postfix/pickup[25160]: 1EAE61AD808C: uid=100 from=<nagios>
Apr 19 15:25:10 host_name postfix/cleanup[7797]: 1EAE61AD808C: message-id=<20110419132510.1EAE61AD808C>
Apr 19 15:25:10 host_name postfix/qmgr[3331]: 1EAE61AD808C: from=<emailaddress>, size=648, nrcpt=1 (queue active)
Apr 19 15:25:10 host_name postfix/qmgr[3331]: 1EAE61AD808C: to=<emailaddress>, relay=none, delay=0.09, delays=0.05/0.03/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to something.be[IP]: Connection timed out)
Apr 19 15:26:10 host_name postfix/pickup[25160]: AC5611AD808D: uid=100 from=<nagios>
Apr 19 15:26:10 host_name postfix/cleanup[7797]: AC5611AD808D: message-id=<20110419132610.AC5611AD808D>
Apr 19 15:26:10 host_name postfix/qmgr[3331]: AC5611AD808D: from=<emailaddress>, size=648, nrcpt=1 (queue active)
Apr 19 15:26:10 host_name postfix/qmgr[3331]: AC5611AD808D: to=<emailaddress>, relay=none, delay=0.35, delays=0.33/0.02/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to something.be[IP]: Connection timed out)
I've put something in bold (way back to the end)
I read some things and probably it has to do something with ISP?!
But when i try this:
Code:
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" email@domain.com
I get an email....

Can someone pls help me with this?!

Thx
 
Old 04-22-2011, 08:16 AM   #8
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi Björn,

Check if you can manually connect to your mail destination using telnet:
Code:
telnet hostname.be 25
that is, if it's a regular mail server. If you're trying to mail to a mailserver like GMail that listens on another port then you'll need to change the port accordingly.

Use the command as this:
Code:
mail -s "Testmail or whatever" user@hostname.be
Hit enter after the above command, that will take you to a new line. Type some text and/or just type CTRL-D. Normally the mailer will ask you if you want to send a copy to other correspondents. If you don't just hit CTRL-D again. Then check your log files and check if you have the same error. Also specify if you are trying to mail to a service like GMail, Yahoo, HotMail. Those are different and have put their limitations in place in order to avoid spam.

Kind regards,

Eric
 
Old 04-22-2011, 08:33 AM   #9
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
I would like to mail to a Hotmail address.

Quote:
Originally Posted by EricTRA View Post
Hi Björn,

Check if you can manually connect to your mail destination using telnet:
Code:
telnet hostname.be 25
that is, if it's a regular mail server. If you're trying to mail to a mailserver like GMail that listens on another port then you'll need to change the port accordingly.
when i do this, i get the following error:
Code:
# telnet hostname 25
Trying IP...
telnet: connect to address IP: Connection refused
telnet: Unable to connect to remote host: Connection refused

Quote:
Originally Posted by EricTRA View Post
Use the command as this:
Code:
mail -s "Testmail or whatever" user@hostname.be
Hit enter after the above command, that will take you to a new line. Type some text and/or just type CTRL-D. Normally the mailer will ask you if you want to send a copy to other correspondents. If you don't just hit CTRL-D again. Then check your log files and check if you have the same error. Also specify if you are trying to mail to a service like GMail, Yahoo, HotMail. Those are different and have put their limitations in place in order to avoid spam.
Code:
# mail -s "bla" nagios@hostname
test
Cc: emailadres (Hotmail)
You have new mail in /var/spool/mail/root
Code:
# tail /var/spool/mail/root
Subject: bla
Cc: emailadres (Hotmail)
Message-Id: <20110422123014.B4ED31AE879F@host>
Date: Fri, 22 Apr 2011 14:30:14 +0200 (CEST)
From: user@host (root)

test

--B4ED31AE879F.1303475414/host--
But when i go to my hotmail , i don't have any messages...
 
Old 04-22-2011, 08:58 AM   #10
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi,

Well, I think you're in bad luck for what concerns your Hotmail connection. Have a look at this thread here at LQ for some possible answers.

Kind regards,

Eric
 
Old 04-22-2011, 09:03 AM   #11
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
should it work with GMAIL?
 
Old 04-22-2011, 09:13 AM   #12
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi,

Nope, same reason, I got it working at my previous job because they had a fixed IP address, where customer using GMail for Enterprises and communicated with GMail in order to be able to relay mails through their servers. If you try to use it as a private person with a dynamic IP then you're out of luck I'm afraid. There are although several tutorials on the internet that claim they have it working with authentication, but I've never tried one of them. If you follow one of them and get it working, I'm sure the community will appreciate you posting your findings/solution.

Kind regards,

Eric
 
Old 04-22-2011, 09:16 AM   #13
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
hmm bummer... if you can show some of those tutorials (i don't know exactly how to search for them) then i'll try one of them
 
Old 04-22-2011, 09:39 AM   #14
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
How can i check how the mail server of Nagios is configured?
Or how can i see which mail server he uses (or port ?)

I don't know if you can, but IF you can, maybe something is wrong in the configuration?!
 
Old 04-22-2011, 10:36 AM   #15
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi,

Some of the tutorials found using 'configure postfix to use gmail' as keywords:
http://www.marksanborn.net/linux/sen...tu-lts-server/
http://jeremypetz.blogspot.com/2010/...-gmail-as.html

Per default Nagios sends mails to the local mailsystem if I recall correctly. So if you want to forward (relay) them you'll have to set your local mailsystem up to do so, for example by following one of the above guides.

Kind regards,

Eric
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I send EOF to wall cmd in a script? jcllings Linux - General 4 05-24-2010 04:36 AM
Postfix : mail cannot send to send outside ( can send/receive locally) bobbinsupport Linux - Networking 3 12-15-2007 11:40 PM
with the linux proxi, backend pop3 mail client can not receive mail and send mail rubin823 Linux - Networking 0 12-21-2006 11:06 PM
"mail" cmd can't send mail to outside MX bret Linux - General 1 09-13-2006 05:05 PM
cmd line send attachment? jedimastermopar Linux - General 2 06-16-2005 01:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration