return ret;
}
+static int
+lmtp_local_default_do_deliver(struct lmtp_local *local,
+ struct lmtp_local_recipient *llrcpt,
+ struct lmtp_local_deliver_context *lldctx,
+ struct mail_deliver_context *dctx)
+{
+ struct smtp_server_recipient *rcpt = llrcpt->rcpt->rcpt;
+ struct mail_storage *storage;
+ enum mail_error mail_error;
+ const char *error;
+
+ if (mail_deliver(dctx, &storage) == 0) {
+ if (dctx->dest_mail != NULL) {
+ i_assert(local->first_saved_mail == NULL);
+ local->first_saved_mail = dctx->dest_mail;
+ }
+ smtp_server_recipient_reply(rcpt, 250, "2.0.0", "%s Saved",
+ lldctx->session_id);
+ return 0;
+ }
+
+ if (dctx->tempfail_error != NULL) {
+ smtp_server_recipient_reply(rcpt, 451, "4.2.0", "%s",
+ dctx->tempfail_error);
+ } else if (storage != NULL) {
+ error = mail_storage_get_last_error(storage, &mail_error);
+ if (mail_error == MAIL_ERROR_NOQUOTA) {
+ lmtp_local_rcpt_reply_overquota(llrcpt, error);
+ } else {
+ smtp_server_recipient_reply(rcpt, 451, "4.2.0", "%s",
+ error);
+ }
+ } else {
+ /* This shouldn't happen */
+ e_error(rcpt->event, "BUG: Saving failed to unknown storage");
+ smtp_server_recipient_reply(rcpt, 451, "4.3.0",
+ "Temporary internal error");
+ }
+ return -1;
+}
+
int lmtp_local_default_deliver(struct client *client,
struct lmtp_recipient *lrcpt,
struct smtp_server_cmd_ctx *cmd ATTR_UNUSED,
struct smtp_address *rcpt_to = rcpt->path;
struct mail_deliver_input dinput;
struct mail_deliver_context dctx;
- struct mail_storage *storage;
struct event *event;
- enum mail_error mail_error;
- const char *error;
int ret;
event = event_create(rcpt->event);
dinput.delivery_time_started = lldctx->delivery_time_started;
mail_deliver_init(&dctx, &dinput);
- if (mail_deliver(&dctx, &storage) == 0) {
- if (dctx.dest_mail != NULL) {
- i_assert(local->first_saved_mail == NULL);
- local->first_saved_mail = dctx.dest_mail;
- }
- smtp_server_recipient_reply(rcpt, 250, "2.0.0", "%s Saved",
- lldctx->session_id);
- ret = 0;
- } else if (dctx.tempfail_error != NULL) {
- smtp_server_recipient_reply(rcpt, 451, "4.2.0", "%s",
- dctx.tempfail_error);
- ret = -1;
- } else if (storage != NULL) {
- error = mail_storage_get_last_error(storage, &mail_error);
- if (mail_error == MAIL_ERROR_NOQUOTA) {
- lmtp_local_rcpt_reply_overquota(llrcpt, error);
- } else {
- smtp_server_recipient_reply(rcpt, 451, "4.2.0", "%s",
- error);
- }
- ret = -1;
- } else {
- /* This shouldn't happen */
- e_error(rcpt->event, "BUG: Saving failed to unknown storage");
- smtp_server_recipient_reply(rcpt, 451, "4.3.0",
- "Temporary internal error");
- ret = -1;
- }
+ ret = lmtp_local_default_do_deliver(local, llrcpt, lldctx, &dctx);
mail_deliver_deinit(&dctx);
event_unref(&event);