iyasar
iyasar

Reputation: 1271

qmail-inject returns 111

Hi i got a problem with qmail. I want to send an email from my program i got 111 error code from qmail-inject. But if i try to send same email from command line it works.

In my code :

if ((pid = fork()) < 0) {
        logger.error("error creating on new process");
}

else if (pid == 0) {
      logger.info("qmail-inject is calling now for Dlp Notify");
      if (execl("/opt/program/bin/sendmail","sendmail", notifySender, tempMail,(char*)   0) == -1)  {
        logger.error("notify operation failed: %s", strerror(errno));
        exit(1);
    }
}

sendmail is a script just like that :

/bin/cat $2 | /opt/smtp/bin/qmail-inject -f   $1

when i run this script on command line that works well. But from my program that doesnt work.

Any help would be appreciated.

Upvotes: 0

Views: 520

Answers (1)

alk
alk

Reputation: 70971

Your C code to execute qmail-inject looks ok, at least from what you show us.

man qmail-inject tells us exit code 111 indicates a temporary error.

qmail-inject's sources (v1.03, which look the same here for netqmail 1.06) show the following:

void temp() { _exit(111); }
void die_nomem() {
 substdio_putsflush(subfderr,"qmail-inject: fatal: out of memory\n"); temp(); }
void die_invalid(sa) stralloc *sa; {
 substdio_putsflush(subfderr,"qmail-inject: fatal: invalid header field: ");
 substdio_putflush(subfderr,sa->s,sa->len); perm(); }
void die_qqt() {
 substdio_putsflush(subfderr,"qmail-inject: fatal: unable to run qmail-queue\n"); temp(); }
void die_chdir() {
 substdio_putsflush(subfderr,"qmail-inject: fatal: internal bug\n"); temp(); }
void die_read() {
 if (errno == error_nomem) die_nomem();
 substdio_putsflush(subfderr,"qmail-inject: fatal: read error\n"); temp(); }

From the latter (together with some more lookups into qmail-inject.c) one could draw the following possible causes for qmail-inject exiting with 111:

  • out of memory
  • invalid header fields(s) (either passed to -f or read from config/control files)
  • unable to run qmail-queue (perhaps due to its non existance, or missing search path to it)
  • being unable to chdir to qmail's control/config file folder
  • being unable to read qmail's config/control files

Checking the logs on your side might help also.

Upvotes: 0

Related Questions