6.4 bounce模块

来源:互联网 发布:文章采集软件 编辑:程序博客网 时间:2024/06/11 02:19

bounce模块是参与基本收发信过程的必要模块。bounce模块为无法发送的邮件、延迟邮件、成功发送的邮件、地址测试请求发送DSN状态提醒信。

 

bounce模块主要有以下功能函数:

bounce_append_service:记录邮件状态。

bounce_verp_proto:按XVERP参数发送退信。

bounce_notify_service:发送退信。

bounce_warn_service:发送邮件延迟提醒信。

bounce_trace_service:发送DSN状态提醒信。

 

为用户发送状态提醒信的函数均使用/global/post_mail.c/post_mail_fopen_nowait函数打开流,这个流正是cleanup模块:

/* post_mail_fopen_nowait - prepare forposting a message */ 259 /* post_mail_fopen_nowait - prepare forposting a message */260261 VSTREAM *post_mail_fopen_nowait(constchar *sender, const char *recipient,262                                         intsource_class, int trace_flags,263                                         intutf8_flags, VSTRING *queue_id)264 {265    VSTREAM *stream;266267    if ((stream = mail_connect(MAIL_CLASS_PUBLIC, var_cleanup_service,268                                BLOCKING)) !=0)269        post_mail_init(stream, sender, recipient, source_class, trace_flags,270                        utf8_flags, queue_id);271    return (stream);272 }

var_cleanup_service即cleanup模块,也即退信等提醒信由bounce模块将信息传递给cleanup模块,进而进入qmgr模块。退信信息由bounce_notify_util.c的bounce_header、bounce_diagnostic_log、bounce_header_dsn、bounce_diagnostic_dsn、bounce_original等函数生成。

 

bounce模块采用single_server.c做模板,在其回调函数bounce_service中要根据其他模块提供的“命令”采用相应的处理:

/*  * Bounce/defer protocol commands.  */#defineBOUNCE_CMD_APPEND    0       /* append log */#defineBOUNCE_CMD_FLUSH       1       /* send log */#defineBOUNCE_CMD_WARN                 2       /* send warning, don't delete log */#defineBOUNCE_CMD_VERP                   3       /* send log, verp style */#defineBOUNCE_CMD_ONE           4       /* send one recipient notice */#defineBOUNCE_CMD_TRACE       5       /* send delivery record */ /bounce/bounce.c/*    * Read and validate the first parameter of the client request. Let the    * request-specific protocol routines take care of the remainder.    */   if (attr_scan(client, ATTR_FLAG_STRICT | ATTR_FLAG_MORE,                     RECV_ATTR_INT(MAIL_ATTR_NREQ, &command),0) != 1) {         msg_warn("malformedrequest");         status= -1;    }else if (command == BOUNCE_CMD_VERP) {         status= bounce_verp_proto(service_name, client);    }else if (command == BOUNCE_CMD_FLUSH) {         status= bounce_notify_proto(service_name, client,                                          bounce_notify_service);    }else if (command == BOUNCE_CMD_WARN) {         status= bounce_notify_proto(service_name, client,                                          bounce_warn_service);    }else if (command == BOUNCE_CMD_TRACE) {         status= bounce_notify_proto(service_name, client,                                          bounce_trace_service);    }else if (command == BOUNCE_CMD_APPEND) {         status= bounce_append_proto(service_name, client);    }else if (command == BOUNCE_CMD_ONE) {         status= bounce_one_proto(service_name, client);    }else {         msg_warn("unknowncommand: %d", command);         status= -1;}

qmgr模块通过/global/abounce.c与bounce模块通信。a代表异步asynchronous。
0 0