c++ - qmail-inject 返回 111

标签 c++ c linux qmail

嗨,我遇到了 qmail 问题。我想从我的程序发送一封电子邮件,我从 qmail-inject 收到 111 错误代码。但如果我尝试从命令行发送相同的电子邮件,它会起作用。

在我的代码中:

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 是一个类似的脚本:

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

当我在命令行上运行这个脚本时效果很好。但从我的程序来看,这是行不通的。

如有任何帮助,我们将不胜感激。

最佳答案

您执行qmail-inject的C代码看起来不错,至少从您向我们展示的内容来看是这样。

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

qmail-inject 的源代码(v1.03,对于 netqmail 1.06 来说看起来相同)显示以下内容:

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(); }

从后者(加上对 qmail-inject.c 的更多查找),我们可以得出 qmail-inject 以 111 退出的以下可能原因:

  • 内存不足
  • 无效的 header 字段(传递给 -f 或从配置/控制文件读取)
  • 无法运行qmail-queue(可能是因为它不存在,或者缺少它的搜索路径)
  • 无法 chdirqmail 的控制/配置文件夹
  • 无法读取 qmail 的配置/控制文件

检查您这边的日志也可能有所帮助。

关于c++ - qmail-inject 返回 111,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13417419/

相关文章:

c - C 中函数的名称

linux - 位置参数和函数

linux - 如何将很棒的 WM 与 LXSession(LXDE、Lubuntu)结合使用

linux - WPS office (alpha) 安装后损坏的 libc.so.6

c++ - 有什么办法可以使 SHFileOperation 成为模态吗?

c++ - 按行反转 ostringstream

c - 使用strtok将字符串解析成单词

c++ - 可以使用 C++14 索引序列改进元组可变参数模板递归吗?

c++ - C++ 循环的编译时评估

c++ - 在屏幕上输出矩形?