LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 01-19-2011, 12:36 AM   #1
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
sendmail - disable local delivery and queue is growing up?


Hi,

I want to setup sendmail to alert for Nagios, OSSEC, redmine, ...

I configure sendmail to work with Gmail smtp follow this guide.
I disable local delivery in sendmail by adding the following lines in sendmail.mc:
Code:
define(`MAIL_HUB', `xx.localdomain.')dnl
define(`LOCAL_RELAY', `xx.localdomain.')dnl
it works but this messages seems to be stuck in sendmail queue:
Code:
sendmail -bp
...
p0IAY17d021939      253 Tue Jan 18 17:34 <root@xx.localdomain>
                 (Deferred: Connection refused by xx.localdomain.)
					 <root@xx.localdomain>
		Total requests: 2057
and is growing up very fast. Yesterday, it was up to 400000 msg. `sendmail -v -q` seems to not work and I must manually delete it from /var/spool/mqueue.

How can I solve this problem?

Below is my sendmail.mc:
Code:
divert(-1)dnl
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
VERSIONID(`setup for linux')dnl
OSTYPE(`linux')dnl
define(`confDEF_USER_ID', ``8:12'')dnl
define(`confTO_CONNECT', `1m')dnl
define(`confTRY_NULL_MX_LIST', `True')dnl
define(`confDONT_PROBE_INTERFACES', `True')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
define(`STATUS_FILE', `/var/log/mail/statistics')dnl
define(`UUCP_MAILER_MAX', `2000000')dnl
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl
define(`confTO_IDENT', `0')dnl
FEATURE(`no_default_msa', `dnl')dnl
FEATURE(`mailertable', `hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl
FEATURE(redirect)dnl
FEATURE(always_add_domain)dnl
FEATURE(use_cw_file)dnl
FEATURE(use_ct_file)dnl

FEATURE(`access_db', `hash -T<TMPF> -o /etc/mail/access.db')dnl
FEATURE(`blacklist_recipients')dnl
EXPOSED_USER(`root')dnl
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
FEATURE(`accept_unresolvable_domains')dnl

FEATURE(`authinfo',`hash /etc/mail/auth/client-info.db')dnl
define(`SMART_HOST',`smtp.gmail.com')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')
define(`ESMTP_MAILER_ARGS', `TCP $h 587')

define(`CERT_DIR', `/etc/mail/certs')
define(`confCACERT_PATH', `CERT_DIR')
define(`confCACERT', `CERT_DIR/ca-bundle.crt')
define(`confCRL', `CERT_DIR/ca-bundle.crt')
define(`confSERVER_CERT', `CERT_DIR/sendmail.pem')
define(`confSERVER_KEY', `CERT_DIR/sendmail.pem')
define(`confCLIENT_CERT', `CERT_DIR/sendmail.pem')
define(`confCLIENT_KEY', `CERT_DIR/sendmail.pem')

define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')

MAILER(smtp)dnl

define(`MAIL_HUB', `xx.localdomain.')dnl
define(`LOCAL_RELAY', `xx.localdomain.')dnl

define(`confQUEUE_LA', `32')dnl
define(`confREFUSE_LA', `48')dnl

define(`confSHARED_MEMORY_KEY', `10000')
 
Old 01-19-2011, 05:35 AM   #2
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
You specify an alias file: define(`ALIAS_FILE', `/etc/aliases')dnl. Do you have root.xx.localdomain mapped as an alias to a valid (gmail) or other address that can receive mail?
 
Old 01-19-2011, 09:58 PM   #3
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Original Poster
Rep: Reputation: 100Reputation: 100
Hi Noway2,

My /etc/aliases remains default, something like this:
Code:
bin:		root
daemon:		root
adm:		root
lp:		root
sync:		root
shutdown:	root
halt:		root
mail:		root
news:		root
Perhaps it is the cause of this.

I don't want to map the root to a valid email address. All I want is sending out mail to alert and completely disable the local delivery (don't go to the queue).

I deleted 2 lines below in sendmail.mc:
Code:
define(`ALIAS_FILE', `/etc/aliases')dnl
EXPOSED_USER(`root')dnl
but mails still send to root and stuck in queue:
Code:
...
p0JFp1Xf025053      253 Wed Jan 19 22:51 <root@SVR040-763.localdomain>
                 (Deferred: Connection refused by svr040-763.localdomain.)
					 <root@SVR040-763.localdomain>
p0JEv21a007790      253 Wed Jan 19 21:57 <root@SVR040-763.localdomain>
                 (Deferred: Connection refused by svr040-763.localdomain.)
					 <root@SVR040-763.localdomain>
p0JFO19w000305      253 Wed Jan 19 22:24 <root@SVR040-763.localdomain>
                 (Deferred: Connection refused by svr040-763.localdomain.)
					 <root@SVR040-763.localdomain>
		Total requests: 1143
Thanks for your help.
 
Old 01-20-2011, 05:37 AM   #4
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
I think we might be misunderstanding each other but trying to say the same things. When I mentioned mapping root to a valid email address, I meant to say map the email address 'root@localhost' to the address to the one where would like your alert emails to be sent, not the root user. By default, when applications send out their alerts they are going to send it to 'root@localhost' and unless your mail handler knows where to redirect the message, it will try to deliver it locally, which it can't and you don't want.

I also found this thread. I think the suggestion by Pawel (the second response) received a lot of comments saying it solved the problem for them.
 
Old 01-20-2011, 10:05 PM   #5
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Original Poster
Rep: Reputation: 100Reputation: 100
Quote:
Originally Posted by Noway2 View Post
I think we might be misunderstanding each other but trying to say the same things.
No, I don't think so.
Quote:
Originally Posted by Noway2 View Post
When I mentioned mapping root to a valid email address, I meant to say map the email address 'root@localhost' to the address to the one where would like your alert emails to be sent, not the root user.
I know, but if I do that, I will get a lot of local messages like this:
Code:
    **********************************************
    **      THIS IS A WARNING MESSAGE ONLY      **
    **  YOU DO NOT NEED TO RESEND YOUR MESSAGE  **
    **********************************************

The original message was received at Fri, 21 Jan 2011 04:05:01 +0700
from SVR040-763.localdomain [127.0.0.1]

   ----- Transcript of session follows -----
<root@SVR040-763.localdomain>... Deferred: Connection refused by svr040-763.localdomain.
Warning: message still undelivered after 4 hours
Will keep trying until message is 5 days old



Reporting-MTA: dns; SVR040-763.localdomain
Arrival-Date: Fri, 21 Jan 2011 04:05:01 +0700

Final-Recipient: RFC822; root@SVR040-763.localdomain
Action: delayed
Status: 4.4.1
Remote-MTA: DNS; svr040-763.localdomain
Last-Attempt-Date: Fri, 21 Jan 2011 08:53:31 +0700
Will-Retry-Until: Wed, 26 Jan 2011 04:05:01 +0700


Part 1.2
Subject:
Cron <root@SVR040-763> /usr/bin/unison -batch
From:
root@SVR040-763.localdomain (Cron Daemon)
Date:
Fri, 21 Jan 2011 04:05:01 +0700
To:
root@SVR040-763.localdomain

Usage: unison [options]
    or unison root1 root2 [options]
    or unison profilename [options]

For a list of options, type "unison -help".
For a tutorial on basic usage, type "unison -doc tutorial".
For other documentation, type "unison -doc topics".
and as you know, that I don't want.
Quote:
Originally Posted by Noway2 View Post
I also found this thread. I think the suggestion by Pawel (the second response) received a lot of comments saying it solved the problem for them.
If you take notice of it, you can see that I read from it to disable the local delivery.
 
Old 01-22-2011, 10:11 AM   #6
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
I have been giving your posts some thought over the past few days. Specifically, I have been trying to understand and reconcile exactly what your problem is and what to do about it, assuming that anything can be. I was hoping that someone else would have some ideas to help you, but it doesn't appear to be the case. So, I will try to recap:
  • You are running sendmail as your local MTA
  • You have configured sendmail to relay to your gmail accounts
  • You have disabled local delivery to Linux accounts
  • You are seeing a large number of undelivered messages addressed to 'root@localhost' appearing in your mail queue
  • You want to receive alerts (emails) from a limited set of applications that you chose, e.g. ossec, Nagios, Redmine.
  • You do not want to forward ALL root@localdomain email to a gmail account, just the services you select?

The problem that I see is that various processes are configured, by default to send mail to root@localdomain. When the applications do this, your sendmail will pickup the messages and try to handle them. If it thinks that it is supposed to handle mail for localdomain it will try to accept the messages and then try to deliver them. It looks like what is happening is that sendmail is accepting these messages, but doesn't know what to do with them. Hence they get queued up in a deferred status. What it sounds like you need to do is stop sendmail from even accepting mail for this user.

My searching is coming up with little in this regard. However, I see this link. Please check it out. Specifically, look at section 28.3.2 on alias. You will notice that bit.bucket is mapped to /dev/null. Perhaps you could map root to /dev/null? This should cause all root@localdomain mail to go into the void. As long as you have configured the desired applications to send mail where you wish, this may achieve your goal.
 
1 members found this post helpful.
Old 01-26-2011, 10:28 PM   #7
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Original Poster
Rep: Reputation: 100Reputation: 100
Problem solved. Noway2, thank you very much.
 
  


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
Setup different local delivery agents for different users in sendmail gedeon Linux - Server 1 06-10-2010 04:12 AM
Sendmail local and relay delivery for domain isak Linux - Server 3 12-02-2009 03:23 PM
Sendmail Delivery errors plugs up the queue alexpacio Linux - Server 2 01-26-2009 05:48 PM
Sendmail local delivery watchamaka Linux - Networking 6 12-13-2003 02:32 PM
sendmail local delivery problems jhildebrand Linux - Networking 0 04-24-2003 04:56 PM


All times are GMT -5. The time now is 04:52 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration