forums.meulie.net

My command to send mails

well
im using my mail server to send the alerts coz i have some problems using the mail command
so i create my own a command

define command{
command_name emailNotify
command_line nc6 myserver 25 <mail.txt
}

mail.txt


helo server
mail from: [email protected]
rcpt to: $CONTACTEMAIL$
data
Subject: testing.
State: $SERVICESTATE$.
Service: $SERVICEDESC$.
.
quit


now… the problem is he dont send the mails T_T!
but if a change the “rcpt to:” for my mail

he send it, but nothing inside
some can give me a hand with this
thx.

possibly adding some newlines to the script might help.

Luca

PS: The mail server you use shouldn’t be a problem for the mail command… you can use the default mail command but giving the complete host name on the email address so you are sure it get’s sent to a particular host instead of the default SMTP server… (possibly needs an alias in the mail server to accept emails for the address which now has the full host name instead of the domain only)
Edited Tue Jan 24 2006, 03:26PM ]

For one thing, how is mail.txt going to get the variable $CONTACTEMAIL$ completed? Looks like magic to me. Does $SERVICESTATE$ get completed?

sorry for answer so late but i was out of city

first Luca, i dont know where to put a SMTP as default to use the mail command, also i dont know well how mail command works… that why i try this script
btw what you mean with “adding some newlines to the script”

jakkedup
that is the same i think and i try to resolve it doing this

define command{
command_name emailNotify
command_line /usr/bin/nc6 myserver 25 <mail.txt $CONTACTEMAIL$ $SERVICESTATE$ $SERVICEDESC$
}

mail.txt


helo server
mail from: [email protected]
rcpt to: $1
data
Subject: testing.
State: $2.
Service: $3.
.
quit


but dont work also not send mail either T_T!
pd: if you mean “$SERVICESTATE$ is completed” when services state is down or UP yes is completed
coz it works once but in the mail dont give me any details
Edited Fri Jan 27 2006, 03:16AM ]

I think it would be easier to go back to the original default format, since all linux boxes come with the mail command installed by default I think.
which mail
man mail
should help, but I don’t see why you are having trouble with the mail command.

i have problems coz im behind a very restricted firewall/proxy server
so the only way to go out with mails is using my mail server
now understand ?

Yes, so just configure sendmail to use “that mailserver”.
I have the same situation, but it doesn’t prevent sendmail from being configed to use a particular server.

hmmmmmm… can give me a hand to configure that ?
i dont know where to configure it T_T!

vi /etc/hosts
add this:
ipaddyofyourmailserver then tab and add mailhost
so it looks like this:
xx.xx.xx.xx mailhost
exit and save from vi.

vi /etc/mail/sendmail.mc
go to the line that says:
define(SMART_HOST', and add this like this: define(SMART_HOST’,`mailhost’)

now read and pay attention to what it said on top of that .mc file.
It says to do this:
make -C /etc/mail
So , exit and save that .mc file and do that command.
make -C /etc/mail
Now you should be able to send mail using any mail client if you are using sendmail as your outbound mail server on your linux box.

Edited Fri Jan 27 2006, 05:15AM ]

mmmmmm…well the problem start in /etc/mail
i dont have it
u install sendmail ? ?
coz i have sendmail as command but anything else
i have /etc/exim4
if this help you