void lmtp_client_send(struct lmtp_client *client, struct istream *data_input) { i_stream_ref(data_input); client->data_input = data_input; (void)lmtp_client_send_data_cmd(client); }
void lmtp_client_send(struct lmtp_client *client, struct istream *data_input) { i_assert(client->data_input == NULL); i_stream_ref(data_input); client->data_input = data_input; /* now we actually want to start doing I/O. start the timeout handling. */ if (client->set.timeout_secs > 0) { if (client->to != NULL) { /* still waiting for connect to finish */ timeout_remove(&client->to); } client->to = timeout_add(client->set.timeout_secs*1000, lmtp_client_timeout, client); } (void)lmtp_client_send_data_cmd(client); }
static int lmtp_client_input_line(struct lmtp_client *client, const char *line) { int ret, reply_code = 0; if ((ret = lmtp_input_get_reply_code(line, &reply_code, client->input_multiline)) <= 0) { if (ret == 0) return 0; lmtp_client_fail(client, line); return -1; } switch (client->input_state) { case LMTP_INPUT_STATE_GREET: case LMTP_INPUT_STATE_XCLIENT: if (reply_code != 220) { lmtp_client_fail(client, line); return -1; } lmtp_client_send_handshake(client); client->input_state = LMTP_INPUT_STATE_LHLO; break; case LMTP_INPUT_STATE_LHLO: case LMTP_INPUT_STATE_MAIL_FROM: if (reply_code != 250) { lmtp_client_fail(client, line); return -1; } str_append(client->input_multiline, line); lmtp_client_parse_capabilities(client, str_c(client->input_multiline)); if (client->input_state == LMTP_INPUT_STATE_LHLO && lmtp_client_send_xclient(client)) { client->input_state = LMTP_INPUT_STATE_XCLIENT; client->xclient_sent = TRUE; break; } if (client->input_state == LMTP_INPUT_STATE_LHLO) { o_stream_nsend_str(client->output, t_strdup_printf("MAIL FROM:%s\r\n", client->set.mail_from)); } client->input_state++; lmtp_client_send_rcpts(client); break; case LMTP_INPUT_STATE_RCPT_TO: lmtp_client_rcpt_next(client, line); if (client->data_input == NULL) break; if (lmtp_client_send_data_cmd(client) < 0) return -1; break; case LMTP_INPUT_STATE_DATA_CONTINUE: /* Start sending DATA */ if (strncmp(line, "354", 3) != 0) { lmtp_client_fail(client, line); return -1; } client->input_state++; if (client->data_header != NULL) o_stream_nsend_str(client->output, client->data_header); lmtp_client_send_data(client); break; case LMTP_INPUT_STATE_DATA: /* DATA replies */ if (lmtp_client_data_next(client, line) < 0) return -1; break; } return 1; }