Postfix扫描邮件结果Action

来源:互联网 发布:诚信荣誉 淘宝网 编辑:程序博客网 时间:2024/06/08 00:55

邮件经过垃圾邮件扫描器扫描后,接收返回结果,进行相应的action。返回结果如下:

  • SMFIR_PROGRESS

    /* * Still working on it. * 仍在努力(正在处理) */case SMFIR_PROGRESS:    if (data_size != 0)    break;    continue;
  • SMFIR_CONTINUE

    /* * Decision: continue processing. * 决定:继续处理 */case SMFIR_CONTINUE:    if (data_size != 0)    break;    MILTER8_EVENT_BREAK(milter->def_reply);
  • SMFIR_ACCEPT

    /* * Decision: accept this message, or accept all further commands * in this SMTP connection. This decision is final (i.e. Sendmail * 8 changes receiver state). * 决定:接受此消息,或接受此SMTP连接中的所有其他命令。 该决定是 * 最终的(即Sendmail 8改变接收器状态)。 */case SMFIR_ACCEPT:    if (data_size != 0)    break;    if (IN_CONNECT_EVENT(event)) {#ifdef LIBMILTER_AUTO_DISCONNECT    milter8_close_stream(milter);#endif    /* No more events for this SMTP connection. */    milter->state = MILTER8_STAT_ACCEPT_CON;    } else {    /* No more events for this message. */    milter->state = MILTER8_STAT_ACCEPT_MSG;    }    MILTER8_EVENT_BREAK(milter->def_reply);
  • SMFIR_DISCARD

    /** Decision: accept and silently discard this message. According * to the milter API documentation there will be no action when * this is requested by a connection-level function. This * decision is final (i.e. Sendmail 8 changes receiver state). * 决策:接受并悄悄地丢弃此消息。根据milter API文档,当一个连接级别 * 的函数请求它时,不会有任何动作。这个决定是最终的(即Sendmail 8改 * 变接收者状态)。 */case SMFIR_DISCARD:    if (data_size != 0)    break;    if (IN_CONNECT_EVENT(event)) {    msg_warn("milter %s: DISCARD action is not allowed "         "for connect or helo", milter->m.name);    MILTER8_EVENT_BREAK(milter->def_reply);    } else {    /* No more events for this message. */    milter->state = MILTER8_STAT_ACCEPT_MSG;    MILTER8_EVENT_BREAK("D");    }
  • SMFIR_REJECT

    /* * Decision: reject connection, message or recipient. This * decision is final (i.e. Sendmail 8 changes receiver state). * 决策:拒绝连接、消息或接收方。这个决定是最终的(即Sendmail 8 * 改变接收者状态)。 */case SMFIR_REJECT:    if (data_size != 0)    break;    if (IN_CONNECT_EVENT(event)) {#ifdef LIBMILTER_AUTO_DISCONNECT    milter8_close_stream(milter);#endif    milter->state = MILTER8_STAT_REJECT_CON;    MILTER8_EVENT_BREAK(milter8_def_reply(milter, "550 5.7.1 Command rejected"));    } else {    MILTER8_EVENT_BREAK("550 5.7.1 Command rejected");    }
  • SMFIR_TEMPFAIL

    /* * Decision: tempfail. This decision is final (i.e. Sendmail 8 * changes receiver state). * 决定:临时失败。这个决定是最终的(即Sendmail 8改变接收者状态)。 */case SMFIR_TEMPFAIL:    if (data_size != 0)    break;    if (IN_CONNECT_EVENT(event)) {#ifdef LIBMILTER_AUTO_DISCONNECT    milter8_close_stream(milter);#endif    milter->state = MILTER8_STAT_REJECT_CON;    MILTER8_EVENT_BREAK(milter8_def_reply(milter,        "451 4.7.1 Service unavailable - try again later"));    } else {    MILTER8_EVENT_BREAK("451 4.7.1 Service unavailable - try again later");    }
  • SMFIR_SHUTDOWN

    /* * Decision: disconnect. This decision is final (i.e. Sendmail 8 * changes receiver state). * 决定:断开连接。这个决定是最终的(即Sendmail 8改变接收者状态)。 */case SMFIR_SHUTDOWN:    if (data_size != 0)    break;#ifdef LIBMILTER_AUTO_DISCONNECT    milter8_close_stream(milter);#endif    milter->state = MILTER8_STAT_REJECT_CON;    MILTER8_EVENT_BREAK(milter8_def_reply(milter, "S"));
  • SMFIR_REPLYCODE

    /* * Decision: "ddd d.d+.d+ text". This decision is final (i.e. * Sendmail 8 changes receiver state). Note: the reply may be in * multi-line SMTP format. * * XXX Sendmail compatibility: sendmail 8 uses the reply as a format * string; therefore any '%' characters in the reply are doubled. * Postfix doesn't use replies as format strings; we replace '%%' * by '%', and remove single (i.e. invalid) '%' characters. * XXX Sendmail兼容性:sendmail 8使用回复作为格式字符串; 因此,答复中 * 的任何'%'字符都翻了一番。 Postfix不使用回复作为格式字符串; 我们用 * '%'替换'%%',并删除单个(即无效)'%'字符。 */case SMFIR_REPLYCODE:    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_BUFFER, milter->buf,              MILTER8_DATA_END) != 0)    MILTER8_EVENT_BREAK(milter->def_reply);    /* XXX Enforce this for each line of a multi-line reply. */    if ((STR(milter->buf)[0] != '4' && STR(milter->buf)[0] != '5')    || !ISDIGIT(STR(milter->buf)[1])    || !ISDIGIT(STR(milter->buf)[2])    || (STR(milter->buf)[3] != ' ' && STR(milter->buf)[3] != '-')    || (ISDIGIT(STR(milter->buf)[4])        && (STR(milter->buf)[4] != STR(milter->buf)[0]))) {    msg_warn("milter %s: malformed reply: %s",         milter->m.name, STR(milter->buf));    milter8_conf_error(milter);    MILTER8_EVENT_BREAK(milter->def_reply);    }    if ((rp = cp = strchr(STR(milter->buf), '%')) != 0) {    for (;;) {        if ((ch = *cp++) == '%')        ch = *cp++;        *rp++ = ch;        if (ch == 0)        break;    }    }    if (var_soft_bounce) {    for (cp = STR(milter->buf); /* void */ ; cp = next) {        if (cp[0] == '5') {        cp[0] = '4';        if (cp[4] == '5')            cp[4] = '4';        }        if ((next = strstr(cp, "\r\n")) == 0)        break;        next += 2;    }    }    if (IN_CONNECT_EVENT(event)) {#ifdef LIBMILTER_AUTO_DISCONNECT    milter8_close_stream(milter);#endif    milter->state = MILTER8_STAT_REJECT_CON;    MILTER8_EVENT_BREAK(milter8_def_reply(milter, STR(milter->buf)));    } else {    MILTER8_EVENT_BREAK(STR(milter->buf));    }
  • SMFIR_QUARANTINE

    /* * Decision: quarantine. In Sendmail 8.13 this does not imply a * transition in the receiver state (reply, reject, tempfail, * accept, discard). We should not transition, either, otherwise * we get out of sync. * 决定:隔离。在Sendmail 8.13中,这并不意味着接收方状态的转换(应 * 答、拒绝、tempfail、accept、丢弃)。我们也不应该过渡,否则我们就会失去同步。 */case SMFIR_QUARANTINE:    /* XXX What to do with the "reason" text? */    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_BUFFER, milter->buf,              MILTER8_DATA_END) != 0)    MILTER8_EVENT_BREAK(milter->def_reply);    milter8_def_reply(milter, "H");    continue;
  • SMFIR_SKIP

     /* * Decision: skip further events of this type. * 决策:跳过这类的进一步事件。 */case SMFIR_SKIP:    if (data_size != 0)    break;    milter->skip_event_type = event;    MILTER8_EVENT_BREAK(milter->def_reply);
  • SMFIR_CHGHEADER

    /* * Modification request: replace, insert or delete * header. Index 1 means the first instance. * 修改请求:替换、插入或删除消息头。索引1表示第一个实例。 */case SMFIR_CHGHEADER:    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_HLONG, &index,              MILTER8_DATA_STRING, milter->buf,              MILTER8_DATA_STRING, milter->body,              MILTER8_DATA_END) != 0)    MILTER8_EVENT_BREAK(milter->def_reply);    /* Skip to the next request after previous edit error. */    if (edit_resp)    continue;    /* XXX Sendmail 8 compatibility. */    if (index == 0)    index = 1;    if ((ssize_t) index < 1) {    msg_warn("milter %s: bad change header index: %ld",         milter->m.name, (long) index);    milter8_conf_error(milter);    MILTER8_EVENT_BREAK(milter->def_reply);    }    if (LEN(milter->buf) == 0) {    msg_warn("milter %s: null change header name",         milter->m.name);    milter8_conf_error(milter);    MILTER8_EVENT_BREAK(milter->def_reply);    }    if (STR(milter->body)[0])    edit_resp = parent->upd_header(parent->chg_context,                       (ssize_t) index,                       STR(milter->buf),                  MILTER8_HDR_SPACE(milter),                       STR(milter->body));    else    edit_resp = parent->del_header(parent->chg_context,                       (ssize_t) index,                       STR(milter->buf));    continue;
  • SMFIR_ADDHEADER

        /*     * Modification request: append header.     * 修改要求:附加头。     */case SMFIR_ADDHEADER:    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_STRING, milter->buf,              MILTER8_DATA_STRING, milter->body,              MILTER8_DATA_END) != 0)    MILTER8_EVENT_BREAK(milter->def_reply);    /* Skip to the next request after previous edit error. */    if (edit_resp)    continue;    edit_resp = parent->add_header(parent->chg_context,                   STR(milter->buf),                   MILTER8_HDR_SPACE(milter),                   STR(milter->body));    continue;
  • SMFIR_INSHEADER

        /*     * Modification request: insert header. With Sendmail 8,     * index 0 means the top-most header. We use 1-based     * indexing for consistency with header change     * operations.     */case SMFIR_INSHEADER:    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_HLONG, &index,              MILTER8_DATA_STRING, milter->buf,              MILTER8_DATA_STRING, milter->body,              MILTER8_DATA_END) != 0)    MILTER8_EVENT_BREAK(milter->def_reply);    /* Skip to the next request after previous edit error. */    if (edit_resp)    continue;    if ((ssize_t) index + 1 < 1) {    msg_warn("milter %s: bad insert header index: %ld",         milter->m.name, (long) index);    milter8_conf_error(milter);    MILTER8_EVENT_BREAK(milter->def_reply);    }    edit_resp = parent->ins_header(parent->chg_context,                   (ssize_t) index + 1,                   STR(milter->buf),                   MILTER8_HDR_SPACE(milter),                   STR(milter->body));    continue;
  • SMFIR_CHGFROM

        /*     * Modification request: replace sender, with optional     * ESMTP args.     */case SMFIR_CHGFROM:    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_STRING, milter->buf,              MILTER8_DATA_MORE) != 0)    MILTER8_EVENT_BREAK(milter->def_reply);    if (data_size > 0) {    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_STRING, milter->body,                  MILTER8_DATA_END) != 0)        MILTER8_EVENT_BREAK(milter->def_reply);    } else {    VSTRING_RESET(milter->body);    VSTRING_TERMINATE(milter->body);    }    /* Skip to the next request after previous edit error. */    if (edit_resp)    continue;    edit_resp = parent->chg_from(parent->chg_context,                 STR(milter->buf),                 STR(milter->body));    continue;
  • SMFIR_ADDRCPT

        /*     * Modification request: append recipient.     */case SMFIR_ADDRCPT:    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_STRING, milter->buf,              MILTER8_DATA_END) != 0)    MILTER8_EVENT_BREAK(milter->def_reply);    /* Skip to the next request after previous edit error. */    if (edit_resp)    continue;    edit_resp = parent->add_rcpt(parent->chg_context,                 STR(milter->buf));    continue;
  • SMFIR_ADDRCPT_PAR

        /*     * Modification request: append recipient, with optional     * ESMTP args.     */case SMFIR_ADDRCPT_PAR:    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_STRING, milter->buf,              MILTER8_DATA_MORE) != 0)    MILTER8_EVENT_BREAK(milter->def_reply);    if (data_size > 0) {    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_STRING, milter->body,                  MILTER8_DATA_END) != 0)        MILTER8_EVENT_BREAK(milter->def_reply);    } else {    VSTRING_RESET(milter->body);    VSTRING_TERMINATE(milter->body);    }    /* Skip to the next request after previous edit error. */    if (edit_resp)    continue;    edit_resp = parent->add_rcpt_par(parent->chg_context,                     STR(milter->buf),                     STR(milter->body));    continue;
  • SMFIR_DELRCPT

        /*     * Modification request: delete (expansion of) recipient.     */case SMFIR_DELRCPT:    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_STRING, milter->buf,              MILTER8_DATA_END) != 0)    MILTER8_EVENT_BREAK(milter->def_reply);    /* Skip to the next request after previous edit error. */    if (edit_resp)    continue;    edit_resp = parent->del_rcpt(parent->chg_context,                 STR(milter->buf));    continue;
  • SMFIR_REPLBODY

        /*     * Modification request: replace the message body, and     * update the message size.     */case SMFIR_REPLBODY:    if (body_edit_lockout) {    msg_warn("milter %s: body replacement requests can't "         "currently be mixed with other requests",         milter->m.name);    milter8_conf_error(milter);    MILTER8_EVENT_BREAK(milter->def_reply);    }    if (milter8_read_data(milter, &data_size,              MILTER8_DATA_BUFFER, milter->body,              MILTER8_DATA_END) != 0)    MILTER8_EVENT_BREAK(milter->def_reply);    /* Skip to the next request after previous edit error. */    if (edit_resp)    continue;    /* Start body replacement. */    if (body_line_buf == 0) {    body_line_buf = vstring_alloc(var_line_limit);    edit_resp = parent->repl_body(parent->chg_context,                      MILTER_BODY_START,                      (VSTRING *) 0);    }    /* Extract lines from the on-the-wire CRLF format. */    for (cp = STR(milter->body); edit_resp == 0     && cp < vstring_end(milter->body); cp++) {    ch = *(unsigned char *) cp;    if (ch == '\n') {        if (LEN(body_line_buf) > 0        && vstring_end(body_line_buf)[-1] == '\r')        vstring_truncate(body_line_buf,                 LEN(body_line_buf) - 1);        edit_resp = parent->repl_body(parent->chg_context,                      MILTER_BODY_LINE,                      body_line_buf);        VSTRING_RESET(body_line_buf);    } else {        VSTRING_ADDCH(body_line_buf, ch);    }    }    continue;
原创粉丝点击