LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   sendmail - disable local delivery and queue is growing up? (http://www.linuxquestions.org/questions/linux-server-73/sendmail-disable-local-delivery-and-queue-is-growing-up-857175/)

quanta 01-19-2011 12:36 AM

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')


Noway2 01-19-2011 05:35 AM

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?

quanta 01-19-2011 09:58 PM

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.

Noway2 01-20-2011 05:37 AM

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.

quanta 01-20-2011 10:05 PM

Quote:

Originally Posted by Noway2 (Post 4231288)
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 (Post 4231288)
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 (Post 4231288)
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.

Noway2 01-22-2011 10:11 AM

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.

quanta 01-26-2011 10:28 PM

Problem solved. Noway2, thank you very much.


All times are GMT -5. The time now is 10:32 PM.