Subject: [sup-talk] Email extensions/alternate emails

From: [email-masked] (Marcus Williams)
Date: Fri, 30 Nov 2007 12:05:27 +0000

Hi -

I've never quite figured out why I'd add alternate emails to my
config/accounts. Last time I used them it appeared that emails coming
into an alternate address used the default email address on that
account to reply with - is this still the case?

I ask because I'm trying to implement support for email extensions
basically an email address like name-someotherid at domain.tld where
-someotherid is the extension. I added an "extensions" config option
that allowed me to add regexes for my extensions. I then extended
account_for to return the correct account given an email that matched
one of these extensions.

But... what I really wanted sup to do then was what I expected it to
do with alternates, is to reply to an email that came in on one of
these extensions with the same email address, not with the account
email address.

What else do I need to do? Is it just a matter of extending the reply
mode code? To do this should I have to create a dummy account/person
object for the extension address to be able to use it (this seems to
be the case)? Is there a better way to handle extensions?

Thanks

Marcus

---

From: [email-masked] (William Morgan)
Date: Sat, 08 Dec 2007 14:00:01 -0800

Hi Marcus,

Great questions and sorry for the delay in replying.

> account to reply with - is this still the case?

I believe it was this way for a while, but only because of a bug. The
current behavior (reply-mode.rb circa line 144) is a sequence of three
steps:

1. First, if the message contains an Envelope-To, X-Original-To, or
   Delivered-To header (in that order of precedence), the address
   in that header is used.

2. If not, if any of the addresses in To: or Cc: are an "account
   address", the DEFAULT address for that account is used.

3. Failing either of those options, the default address of the default
   account is used.

Step #1 is the most important, and I think it should capture what you
describe below. But that particular selection and sequence of headers
was determinted empirically, by me, so it may need adjustment.

So the alternate emails on an account aren't directly useful for
replies, since they won't ever be used as a From: unless they happen to
have come in on a Delivered-To/Envelope-To/etc header, in which case the
fact that they're an alternate email is irrelevant.

But they are used to determine when a message is to or cc you (the ">"
and "+" widgets you see in thread-index-mode).

> account_for to return the correct account given an email that matched

An excellent idea. There actually was something like that in Sup
much earlier, but was the victim of a refactor at some point.

> these extensions with the same email address, not with the account

Does it not do this in recent SVN checkouts? If not, is there a header
like Delivered-To: in the incoming email that contains the address?

-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Marcus Williams)
Date: Sun, 09 Dec 2007 21:18:34 +0000

>    Delivered-To header (in that order of precedence), the address

Ah. That might be all I needed to know. I'll make sure I'm getting one
of these headers and see if that makes the difference. That also
explains why some of my mail goes out from the wrong address even when
I have got an account set up for it.

Will update once I've played a bit more.

Marcus

---

From: [email-masked] (William Morgan)
Date: Sun, 09 Dec 2007 13:42:01 -0800

> I have got an account set up for it.

Yeah, I don't think the current behavior is 100% correct, yet, so I'm
open to suggestions.

---

From: [email-masked] (Marcus Williams)
Date: Mon, 10 Dec 2007 15:28:23 +0000

> Yeah, I don't think the current behavior is 100% correct, yet, so I'm

I added an envelope-to header but that hasnt changed its current
behaviour. Where in the code does this checking (or is it via
RubyMail)? Have searched code for envelope-to and have only found
mention of it in mbox.rb

If I can figure out why its going wrong I'll have a go at fixing it
even if its just for my case (which will mean for qmail+vpopmail).

Marcus

---

From: [email-masked] (William Morgan)
Date: Mon, 10 Dec 2007 09:37:07 -0800

> RubyMail)? Have searched code for envelope-to and have only found

reply-mode.rb line 23, and message.rb line 112.

---

From: [email-masked] (Marcus Williams)
Date: Mon, 10 Dec 2007 22:28:18 +0000

> reply-mode.rb line 23, and message.rb line 112.

Not sure how I missed that, but there we go. Attached is a patch to
allow for mail extensions via regexes. This adds a :extensions: option
to the config.yaml something like:

:extensions:
 - marcus-sites-\[email-masked]
 - marcus-lists-\[email-masked]

 Which makes sup recognise addresses such as
 marcus-sites-amazon at domain.com and marcus-lists-sup at domain.com as
 account addresses.

 Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: extensions-diff
Type: application/octet-stream
Size: 1231 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071210/5ab6176d/attachment.obj

---

From: [email-masked] (Marcus Williams)
Date: Mon, 10 Dec 2007 22:36:03 +0000

>  marcus-sites-amazon at domain.com and marcus-lists-sup at domain.com as

... forgot to add - by adding the Envelope-To in my setup I get the
correct reply addresses elsewhere as well. My aliases/extensions are a
bit strange in that they dont create delivered-to/env-to/x-orig-to in
a way that is sensible (this is a bug in vpopmail in my view, but
other people disagree) - for now, /usr/bin/formail is my friend!.

Marcus

---

From: [email-masked] (William Morgan)
Date: Thu, 13 Dec 2007 17:03:58 -0800

Excerpts from Marcus Williams's message of Mon Dec 10 14:36:03 -0800 2007:
> correct reply addresses elsewhere as well.

Just curious---what do you mean by adding Envelope-To to your setup? Did
you patch Sup to add this header, or is it added elsewhere in the
process?

---

From: [email-masked] (Marcus Williams)
Date: Fri, 14 Dec 2007 10:10:14 +0000

> you patch Sup to add this header, or is it added elsewhere in the

Added it at the MTA level on my server. 

Marcus

---

From: [email-masked] (William Morgan)
Date: Sun, 06 Jan 2008 11:46:44 -0800

Hi Marcus,

>  - marcus-lists-\[email-masked]

I've added your patch to git after a few tweaks. I renamed "extensions"
to "regexen" since really it does a full regex match against the entire
email address. Hope you don't mind. :) Try it and let me know if it
works for your current setup.

Thanks!

---

From: [email-masked] (Marcus Williams)
Date: Mon, 07 Jan 2008 12:35:20 +0000

> works for your current setup.

Nice :) Works here anyway!

Marcus