LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 11-13-2008, 10:35 AM   #1
jackie001
LQ Newbie
 
Registered: Nov 2008
Posts: 7

Rep: Reputation: 0
eSMTP subject line


Does anyone know the syntax to use for subject when sending mail using esmtp at the command line? Example:
echo "text message" | /usr/bin/esmtp - C /etc/esmtprc myemail -f sendingemail
For SMTP -S "subject" is added at the end but this doesnt work for esmtp, I have tried all of the man pages I could find but strangely, its not there!
Thanks for any advice
 
Old 11-13-2008, 11:28 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,617

Rep: Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963
Quote:
Originally Posted by jackie001 View Post
Does anyone know the syntax to use for subject when sending mail using esmtp at the command line? Example:
echo "text message" | /usr/bin/esmtp - C /etc/esmtprc myemail -f sendingemail
For SMTP -S "subject" is added at the end but this doesnt work for esmtp, I have tried all of the man pages I could find but strangely, its not there!
Thanks for any advice
From the documentation page http://esmtp.sourceforge.net/esmtp.1.html

------------
Esmtp does not attempt to provide all the functionality of sendmail: it is intended to be used by mail user agents as mutt.
------------

Sendmail and mailx can do what you'd like, but esmtp won't.
 
Old 11-14-2008, 03:18 AM   #3
jackie001
LQ Newbie
 
Registered: Nov 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for your response TBone.
So there is no way to include a subject line with eSMTP?
I am tryin to use eSMTP with Nagios and I'm stuck at the following line in the commands.cfg file:


command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotificatio$... | /usr/bin/esmtp -C /etc/esmtprc me@myemail.com - f nagios@email.com -s "** $NOTIFICATIONTYPE$ Host...


How will i include the rest of the information without an -s command?
 
Old 11-14-2008, 03:46 AM   #4
i_nomad
Member
 
Registered: Mar 2008
Distribution: RedHatES4
Posts: 144

Rep: Reputation: 15
Can I ask, what is it you want Nagios to do?
What information are you trying to output into the subject?
If you configure Nagios correctly it will automatically add "Problem alert:Host down, recovered etc" into the subject header
Maybe I am barking up the wrong tree..
Regards
 
Old 11-14-2008, 04:03 AM   #5
jackie001
LQ Newbie
 
Registered: Nov 2008
Posts: 7

Original Poster
Rep: Reputation: 0
I am trying to send out email notifications with the following in the commands.cfg file:

# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios*****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/esmtp - C ~/esmtprc kellyjackie@eircom.net -f nagios@dpd.ie -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$

If i leave out the -s will it still work?
Sorry if this seems like a stupid question but i really am a newbie.
Thanks for any advice



}
 
Old 11-14-2008, 04:20 AM   #6
i_nomad
Member
 
Registered: Mar 2008
Distribution: RedHatES4
Posts: 144

Rep: Reputation: 15
You can refer to http://nagios.sourceforge.net/docs/2_0/toc.html

Does this exist: /usr/bin/esmtp?
or does this exist: /bin/mail?

The default in commands.cfg is:
define command{
command_name host-notify-by-email
command_line /usr/bin/printf "%b" "Notification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$
}
 
Old 11-14-2008, 05:06 AM   #7
jackie001
LQ Newbie
 
Registered: Nov 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for the response.
I have read the documentation. It describes the theory of notifications but not how to set them up. Maybe ill include my other configuration files here in case im missing something else.

I had the default like this in the commands.cfg file but it didnt seem to work so i made those changes to it to work with esmtp.

Yes those files are there: /usr/bin/mail and /usr/bin/esmtp
I have installed and tested esmtp and know that it works. I dont know how mail works, if you can give me an example of how to test it I can run a test from the command line and determine if the other configurations are at fault instead.Note: i dont have postfix installed, only esmtp and procmail.

The other config file i have altered to get the email notifications to work is the contatcs.cfg file, here is an extract:

define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from ge$
alias Nagios Admin ; Full name of user
host_notifications_enabled 1
service_notifications_enabled 1
host_notification_period 24x7
service_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email myemail@email.com ; <<***** CHANGE THIS TO YOUR EM$
}

Here is an extract from the windows.cfg file. I have not made any further alterations to this file to configure email notifications. When i added lines such as enable_nofifications=1, upon restart i would get errors. Should i also add lines to the windows.cfg file? I have read the documentation and the book but im still confused.

define host{
use windows-pcs ; Inherit default values from a template
host_name invoicepc ; The name we're giving to this host
alias invoicingpc ; A longer name associated with the host
address x.x.x.x ; IP address of the host
}

define hostgroup{
hostgroup_name windows-pcs ; The name of the hostgroup
alias Windows PCs ; Long name of the group
members invoicepc
}

define service{
use generic-service
hostgroup_name windows-pcs
service_description Uptime
check_command check_nt!UPTIME
contact_groups admins
}
 
Old 11-14-2008, 05:27 AM   #8
i_nomad
Member
 
Registered: Mar 2008
Distribution: RedHatES4
Posts: 144

Rep: Reputation: 15
Try to follow this logic and match with yours and check the contact names carefully, in your case nagiosadmin, admins etc.
Is the check_nt!UPTIME plugin present?
Is your nagios.cfg pointing to correct files in terms ofcommand def and service/host definition? You need 2 files one for Command definitions and the other for host and service definitions for monitoring this machine.




define service{
name local-service
use generic-service
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 1440
notification_period 24x7
register 0
}

define contactgroup{
contactgroup_name admins
alias whatever...
members admin
}


define contact{
contact_name admin
alias whatever
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email x@x.com
}

Last edited by i_nomad; 11-14-2008 at 05:50 AM.
 
Old 11-17-2008, 06:10 AM   #9
jackie001
LQ Newbie
 
Registered: Nov 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for the reply.
I checked the files and plugins theyre all present. The web interface is working perfectly well, checking all of the services it should. However emails do not arrive at my email address. Im just confused now
 
Old 11-18-2008, 04:08 AM   #10
i_nomad
Member
 
Registered: Mar 2008
Distribution: RedHatES4
Posts: 144

Rep: Reputation: 15
You need to verify if your mail is working.
Is port 25 listening #netstat -tanp
Telnet on to server on port 25 and send a test mail
#telnet xxx 25
#ehlo xxx
#mail from: xxx
#mail rcpt to: yyy
#data
type message
.

Check the mail logs (/var/log/maillog) to see what is happening.

Regards
 
  


Reply



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
Can I edit the subject line in my own post? arjay LQ Suggestions & Feedback 5 06-24-2006 02:23 PM
Procmail Filtering Using a Full Subject Line lmcilwain Linux - Software 3 02-08-2006 01:07 PM
SpamAssassin won't rewrite Subject line mindfrost82 Linux - Software 2 09-18-2005 10:16 AM
Spamassasin, Tagging Subject line lapthorn Linux - Networking 1 09-30-2004 04:19 PM
suggestions for subject line when posting. abrakadabra LQ Suggestions & Feedback 14 05-16-2002 09:03 PM

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

All times are GMT -5. The time now is 05:39 AM.

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
Open Source Consulting | Domain Registration