On 08/22/2011 05:54 PM, Daniel Schütze wrote:
> Paul
>
>
>
> Thank you, that clears that up, we did not have any aliases set up
> before (in dbmail_aliases). I’ve added an alias to one account and the
> auto reply fires off, unfortunately for me however the reply is from
> username@domain. Is there a way to specify which alias is used for the
> auto reply using this system?
Mmm.
The From on the reply is currently decided as follows:
- use the Delivered-To header if it exists
- else, use the envelope recipient,
- else, use the POSTMASTER value specified in dbmail.conf
Seems a bit convoluted to me.
Perhaps we should simply use the alias that matched either To or CC...
you might try the attached patch which does just that.
--
________________________________________________________________
Paul J Stevens pjstevns @ gmail, twitter, skype, linkedin
* Premium Hosting Services and Web Application Consultancy *
www.nfg.nl/[email protected]/+31.85.877.99.97
________________________________________________________________
>From b948110d169d3a1a9f4669e6a3433184f2532aea Mon Sep 17 00:00:00 2001
From: Paul J Stevens <[email protected]>
Date: Mon, 22 Aug 2011 18:53:57 +0200
Subject: [PATCH] set the sender of the auto-reply message to the recipient address
---
pipe.c | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/pipe.c b/pipe.c
index 778bee2..ac52835 100644
--- a/pipe.c
+++ b/pipe.c
@@ -334,9 +334,9 @@ int send_vacation(struct DbmailMessage *message,
* Send an automatic reply.
*/
#define REPLY_DAYS 7
-static int check_destination(struct DbmailMessage *message, GList *aliases)
+static char * check_destination(struct DbmailMessage *message, GList *aliases)
{
- gboolean check = FALSE;
+ gchar * check = NULL;
GList *to, *cc, *recipients;
to = dbmail_message_get_header_addresses(message, "To");
cc = dbmail_message_get_header_addresses(message, "Cc");
@@ -351,7 +351,7 @@ static int check_destination(struct DbmailMessage *message, GList *aliases)
char *alias = (char *)aliases->data;
if (alias && MATCH(alias, addr)) {
TRACE(TRACE_DEBUG, "valid alias found as recipient [%s]", alias);
- check = TRUE;
+ check = g_strdup(alias);
break;
}
if (! g_list_next(aliases)) break;
@@ -367,9 +367,10 @@ static int check_destination(struct DbmailMessage *message, GList *aliases)
static int send_reply(struct DbmailMessage *message, const char *body, GList *aliases)
{
- const char *from, *to, *subject;
+ const char *to, *subject;
const char *x_dbmail_reply;
char *handle;
+ char *from = NULL;
int result;
x_dbmail_reply = dbmail_message_get_header(message, "X-Dbmail-Reply");
@@ -378,18 +379,12 @@ static int send_reply(struct DbmailMessage *message, const char *body, GList *al
return 0;
}
- if (! check_destination(message, aliases)) {
+ if (! (from = check_destination(message, aliases))) {
TRACE(TRACE_MESSAGE, "no valid destination ");
return 0;
}
subject = dbmail_message_get_header(message, "Subject");
- from = dbmail_message_get_header(message, "Delivered-To");
-
- if (!from)
- from = message->envelope_recipient->str;
- if (!from)
- from = ""; // send_mail will change this to DEFAULT_POSTMASTER
to = dbmail_message_get_header(message, "Reply-To");
if (!to)
@@ -406,6 +401,7 @@ static int send_reply(struct DbmailMessage *message, const char *body, GList *al
handle = dm_md5((const unsigned char * const)body);
if (db_replycache_validate(to, from, handle, REPLY_DAYS) != DM_SUCCESS) {
+ g_free(from);
g_free(handle);
TRACE(TRACE_DEBUG, "skip auto-reply");
return 0;
@@ -423,6 +419,7 @@ static int send_reply(struct DbmailMessage *message, const char *body, GList *al
db_replycache_register(to, from, handle);
}
+ g_free(from);
g_free(handle);
g_free(newsubject);
dbmail_message_free(new_message);
--
1.7.4.1
_______________________________________________
DBmail mailing list
[email protected]
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail