 |
 |
Using "mail -s" on OS X client box
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
For some time now I've been using something like echo "LDAP backup successful at $time on $server" | mail -s "Backup successful" me@email.com to send various status updates to myself from my Mac OS X servers. I don't have any mail server configured on any of my servers. I recently tried to implement a script on my Mac OS X client box that utilized mail in the same way. The script runs but I receive no e-mails.
In troubleshooting the problem I found that the mail command simply does not send mail from my OS X client machine. Now I know that using "mail" is sent from the localhost, and not through an smtp server, and that some mail servers do not honor these type of messages, but what gives?
Is there something so functionally different between OS X server and client in this regard?
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
I just tested this on my workstation at work (OS X Client) and it worked fine. So now my question is, what's up? Does anyone else use something like this for e-mail notifications of server happenings?
I suppose I could look into replacing the logging subsystem with Metalog, as it has support for notification via e-mail on certain conditions.
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Apr 2002
Location: Red Bluff, CA
Status:
Offline
|
|
omg you've been ForumGrowl sniped.
did you realize that there was an e-mail notification display plugin for Growl? basically you can choose to send notifications to a specific e-mail address. so you could probably write a fun shellscript that calls growlnotify though i'm not sure which method it uses to send the e-mail. 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by darkcore:
omg you've been ForumGrowl sniped. 
did you realize that there was an e-mail notification display plugin for Growl? basically you can choose to send notifications to a specific e-mail address. so you could probably write a fun shellscript that calls growlnotify though i'm not sure which method it uses to send the e-mail.
Nah, just let me know when the growl blender and toaster come along. I like growl a lot, but I think I need to find out what's wrong with my "mail" first. I get 750 failed attempts to log in to my computer and I wanna know aobut it, damnit.
I actually did think that it would be cool to pipe into growlnotify for my server notifications, but then I realized that I'm never actually at my servers. Writing something to register with growl and utilize the "mail me" notification seems more complex that my cheezy little cron/shell script combo.

|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Interesting, I don't know why I didn't get this mail message earlier, but I saw this just now:
Diagnostic-Code: X-Postfix; host smtp-mx.mac.com[17.250.248.49] said: 553 5.1.8 <theman@nacho.local>... Domain of sender address theman@computer.local does not exist (in reply to MAIL FROM command)
My machine at home is NAT'd, it has no real hostname. My server and my workstation at work have proper hostnames. It looks like the mail servers are dropping the mail...
As a test I set my computer's hostname to a domain I own (thefro.org):
Code:
[aorth@nacho: ~]$ sudo hostname thefro.org
[aorth@nacho: ~]$ hostname
thefro.org
Upon the next run of my script everything was fine and I received a text message a few seconds later. What I don't understand is, why didn't I see more "You have new mail" messages in the terminal? I probably tried it 10 times lastnight, but I only got one message.
This works for now, but that's not a legit hostname for this machine. It will change back to "computername.local" if I ever reboot (unless I change it in /etc/hostconfig, I assume). There's no real downside to this approach, is there?
(Last edited by [APi]TheMan; Dec 6, 2004 at 02:27 AM.
)
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status:
Offline
|
|
It is a little unclear what you are trying to send from where and to where (exactly)... using what.
Yes many MTAs will reject mail from non-real domains/hosts/IPs... this is a good thing.
The command 'mail' will only send if sendmail is running or if it is set to use another external MTA. Whether or not that email gets accepted or rejected at the receiving end is another matter.
I use a similar facility as the one you cooked up called 'logwatch' ( http://www.logwatch.org) which doesn't seem to have been ported to Mac OS X yet via Fink or Apple. Sends me a nice little report each day.
|
|
-DU-...etc...
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by utidjian:
It is a little unclear what you are trying to send from where and to where (exactly)... using what.
Ah. I am trying to send e-mails from the server on which I am monitoring logs to my e-mail address using the command line "mail" program.
Originally posted by utidjian:
Yes many MTAs will reject mail from non-real domains/hosts/IPs... this is a good thing.
That's just the thing, I wasn't sure why sending mail via "mail -s" wasn't working. See, I tried it on several different OS X machines and it worked from all but my home machine. It didn't hit me until afterwards, but my home machine is NAT'd (so it doesn't have a real hostname.
Originally posted by utidjian:
The command 'mail' will only send if sendmail is running or if it is set to use another external MTA. Whether or not that email gets accepted or rejected at the receiving end is another matter.
"mail" must launch postfix when it needs it, as I do not run a mail transfer agent (a.k.a. "MTA") on any of the three machines I tested this on.

|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status:
Offline
|
|
Originally posted by [APi]TheMan:
"mail" must launch postfix when it needs it, as I do not run a mail transfer agent (a.k.a. "MTA") on any of the three machines I tested this on.
Quite right you are. I did a few tests and there seems to be a "master" and "postfix-watch" and perhaps a few others waiting for such an email.
|
|
-DU-...etc...
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by utidjian:
Quite right you are. I did a few tests and there seems to be a "master" and "postfix-watch" and perhaps a few others waiting for such an email.
I usually just figured it was magic that I could send mail from the command line without even using an smtp. I guess it's not too important that the hostname you set your machine to is a valid host if you don't care about it actually resolving. My MTA obviously doesn't seem to mind, I've been masquerading around as apple.com all day!
Hah. :-P
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2001
Status:
Offline
|
|
I use a similar facility as the one you cooked up called 'logwatch' ( http://www.logwatch.org) which doesn't seem to have been ported to Mac OS X yet via Fink or Apple. Sends me a nice little report each day.
I only took a brief look, but it appears logwatch is nothing but Perl scripts, so it should run fine on OS X. I haven't tried it though.
Wade
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|