Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2006-04-27
Medium Priority
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 mailRelay.xxx.net

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=<200604041807.k34I74o9022240@x.xxx.net>, relay=root@localhost

Apr 4 14:07:15 xserverx sendmail[22240]: k34I74o9022240: to=x@xxx.com, 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
  • 6
  • 3

Author Comment

ID: 16553390
As an afterthought, I'm adding more detail to whittle down possibilites.
Below is from sendmail.mc

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

Accepted Solution

anfi earned 2000 total points
ID: 16556251
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 http://www.sendmail.org/security/secure-install.html
If you want sendmail to send locally submitted messages to another host then
1) modify submit.cf (not sendmail.cf). In submit.mc change the last line to contain your smart host IP instead of
  FEATURE(`msp', `[]')dnl
and generate new /etc/mail/submit.cf [not /etc/mail/sendmail.cf]
2) Change the cron command to flush "client" queue instead of main queue
/usr/sbin/sendmail -q -Ac

Author Comment

ID: 16557145
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 me@here.com  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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 16557160
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?

Expert Comment

ID: 16557418
In "normal" situations locally submitted messages will be send "at once" to relay configured in submit.cf.

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 somebody@example.com

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/sendmail.cf
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

ID: 16557565
From my submit.cf
# queue directory
O QueueDirectory=/var/spool/clientmqueue

Author Comment

ID: 16557630
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

ID: 16557654
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]

Expert Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
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…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

571 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