Attempting "sendmail -q" via cron without sendmail service running

Posted on 2006-04-27
Last Modified: 2013-12-17
Desired Scenario:
I want sendmail service off by default.  As system services send alert emails they will backup in the Q.  I want to use cron to flush the Q every 10 minutes via

I setup cron to clear out the mail Q every 10 minutes.  
 */10 * * * * /usr/sbin/sendmail -q

If I have the service running all is well, but when I stop sendmail the sendmail -q command causes this in /var/log/maillog.
 Apr 4 14:07:15 xserverx sendmail[22240]: k34I74o9022240: from=root,
size=17, class=0, nrcpts=1,
msgid=<>, relay=root@localhost

Apr 4 14:07:15 xserverx sendmail[22240]: k34I74o9022240:, ctladdr=root (0/0), delay=00:00:11, xdelay=00:00:00,
mailer=relay, pri=30017, relay=[] [], dsn=4.0.0,
stat=Deferred: Connection refused by []

It appears I can't send the email because the MUA was attempting to connect to the MTA (sendmail) locally instead of using the relay server, but I'm obviously missing something.
If I start sendmail and run sendmail -q all is well, but that defeats the purpose.  Please advise.  
Question by:slocoach

    Author Comment

    As an afterthought, I'm adding more detail to whittle down possibilites.
    Below is from

    dnl # Uncomment and edit the following line if your outgoing mail needs to
    dnl # be sent out through an external mail server:
    dnl #
    LVL 6

    Accepted Solution

    The entries are not caused by your cron command.

    Sendmail-8.12+ sends locally submitted messages via SMTP to It allowed installation without set root id binary. It is described at
    If you want sendmail to send locally submitted messages to another host then
    1) modify (not In change the last line to contain your smart host IP instead of
      FEATURE(`msp', `[]')dnl
    and generate new /etc/mail/ [not /etc/mail/]
    2) Change the cron command to flush "client" queue instead of main queue
    /usr/sbin/sendmail -q -Ac

    Author Comment

    Thanks for the fast response.  I think that worked, at the very least I can send mail out.  
    I'm curious as to how I can test the Q though.
    If I sendmail  blah .   The email is immediately sent instead of being put into any Q.

    Does that have anything to do with this?
    [root@as1 mail]# /usr/sbin/sendmail -q
    No local mailer defined
    QueueDirectory (Q) option must be set

    Author Comment

    And I will change the cron task to /usr/sbin/sendmail -q -Ac .  I'm just curious as to how this can be tested.  How can I Q up some "client" jobs to flush?
    LVL 6

    Expert Comment

    In "normal" situations locally submitted messages will be send "at once" to relay configured in

    Periodic flushing of "client queue" is required only to repeat delivery attempts in case of  (sporadic) delivery problems  e.g. network problems OR overload of the receiving sendmail OR maintanance shutdown of the receiving host. You may see *weeks* without the cron job pushing any queued mail not delivered by "at once" delivery attempt.

    If you want to test cron based client queue runs the send a message in queue delivery mode:
        (echo subject: test ; echo) | /usr/sbin/sendmail -odq -oi

    You can check client queue content using:
       mail -Ac

    ABOUT "/usr/sbin/sendmail -q" reporting "No local mailer defined"
    most likely it marks lack of proper /etc/mail/
    IF you do not plan to start local sendmail daemon AND "/usr/sbin/sendmail -q -Ac" does not report similar problems THEN you may ignore it.

    Author Comment

    From my
    # queue directory
    O QueueDirectory=/var/spool/clientmqueue

    Author Comment

    Re:IF you do not plan to start local sendmail daemon AND "/usr/sbin/sendmail -q -Ac" does not report similar problems THEN you may ignore it.

    Yes, that is the intention and the sendmail -q -Ac command does not create the Q error in the maillog.
    However, i'm curious.  If I did plan on starting the local sendmail daemon how would I fix it?  
    If you prefer, I can start another question with some points attached to continue this dialog.

    This has been enlightening.  I really appreciate the help.  

    Author Comment

    Couldn't check on my Q:

    [root@xxx /]# mail -Ac
    mail: invalid option -- A
    Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
                [- sendmail-options ...]
           mail [-iInNv] -f [name]
           mail [-iInNv] [-u user]
    LVL 6

    Expert Comment

    Sorry, it was *my* typing mistake. I meant:
       mailq -Ac

    Featured Post

    Don't lose your head updating email signatures!

    Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users should you!

    Join & Write a Comment

    I have seen a lot of questions on EE where there have been problems sending out emails to one or more external email domains and most issues can be resolved fairly simply by checking to see that your Mail Server configuration is setup optimally and …
    Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
    To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
    The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now