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 |
Quote:
------------ 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. |
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? |
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 |
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 } |
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$ } |
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 } |
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 } |
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 |
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 |
All times are GMT -5. The time now is 12:59 AM. |