mail-deliver.c revision fcf9e8a625f7bfda6a108b074c420d4085d21ad3
/* Copyright (c) 2005-2015 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "str.h"
#include "str-sanitize.h"
#include "time-util.h"
#include "unichar.h"
#include "var-expand.h"
#include "message-address.h"
#include "lda-settings.h"
#include "mail-storage.h"
#include "mail-namespace.h"
#include "duplicate.h"
#include "mail-deliver.h"
static const char *lda_log_wanted_headers[] = {
"From", "Message-ID", "Subject",
};
static enum mail_fetch_field lda_log_wanted_fetch_fields =
{
struct message_address *addr;
const char *str;
return NULL;
(const unsigned char *)str,
}
static void
struct var_expand_table *tab)
{
#define VAR_EXPAND_SESSION_TIME_IDX 7
int delivery_time_msecs;
}
static const struct var_expand_table *
const char *message)
{
static struct var_expand_table static_tab[] = {
};
struct var_expand_table *tab;
const char *str;
str = "";
}
return tab;
}
const struct var_expand_table *
{
}
const struct var_expand_table *
const char *message)
{
}
static void
{
const struct var_expand_table *src;
struct var_expand_table *dest;
unsigned int i, len;
for (i = 0; i < len; i++) {
}
}
{
const char *msg;
return;
/* update %$ */
}
struct mail_deliver_session *mail_deliver_session_init(void)
{
struct mail_deliver_session *session;
return session;
}
{
}
{
struct mail_namespace *ns;
enum mailbox_flags flags =
*error_str_r = NULL;
if (!uni_utf8_str_is_valid(name)) {
*error_str_r = "Mailbox name not valid UTF-8";
return -1;
}
/* delivering to a namespace prefix means we actually want to
deliver to the INBOX instead */
name = "INBOX";
}
/* deliveries to INBOX must always succeed,
regardless of ACLs */
}
if (mailbox_open(box) == 0)
return 0;
return -1;
/* try creating it. */
if (*error_r != MAIL_ERROR_EXISTS)
return -1;
/* someone else just created it */
}
if (ctx->lda_mailbox_autosubscribe) {
/* (try to) subscribe to it */
}
/* and try opening again */
if (mailbox_open(box) < 0) {
return -1;
}
return 0;
}
{
struct mailbox_metadata metadata;
const guid_128_t *guid;
/* just play it safe and assume a duplicate */
return TRUE;
}
/* there shouldn't be all that many recipients,
so just do a linear search */
return TRUE;
}
return FALSE;
}
struct mail_save_context *save_ctx)
{
struct mailbox_transaction_context *trans =
return;
/* avoid storing duplicate GUIDs to delivered mails to INBOX. this
happens if mail is delivered to same user multiple times within a
session. the problem with this is that if GUIDs are used as POP3
UIDLs, some clients can't handle the duplicates well. */
}
}
struct mail_storage **storage_r)
{
struct mailbox_transaction_context *t;
struct mail_save_context *save_ctx;
struct mailbox_header_lookup_ctx *headers_ctx;
struct mail_keywords *kw;
enum mail_error error;
bool default_save;
int ret = 0;
if (default_save)
mailbox_free(&box);
}
return -1;
}
if (ctx->save_dest_mail)
save_ctx = mailbox_save_alloc(t);
ret = -1;
else
if (ret < 0)
else
if (ret == 0) {
if (ctx->save_dest_mail &&
t = mailbox_transaction_begin(box, 0);
NULL);
/* copying needs the message body. with maildir we also
need to get the GUID in case the message gets
expunged */
}
}
} else {
}
mailbox_free(&box);
return ret;
}
{
return ctx->src_envelope_sender;
}
{
static int count = 0;
return t_strdup_printf("<dovecot-%s-%s-%d@%s>",
}
struct mail_storage *storage)
{
enum mail_error error;
return TRUE;
return error == MAIL_ERROR_TEMP;
}
return FALSE;
}
struct mail_storage **storage_r)
{
int ret;
if (deliver_mail == NULL)
ret = -1;
else {
/* if message was saved, don't bounce it even though
the script failed later. */
} else {
/* success. message may or may not have been saved. */
ret = 0;
}
return -1;
}
/* plugins didn't handle this. save into the default mailbox. */
return -1;
}
/* still didn't work. try once more to save it
to INBOX. */
}
return ret;
}
{
return old_hook;
}