Subject: [sup-talk] return-path

From: [email-masked] (Gabriel Sean Farrell)
Date: Wed, 23 Jan 2008 16:13:18 -0500

I'm writing this message in mutt instead of sup because I send my email
via a postfix relay-host and mutt allows me to set my Return-Path equal
to my "From:" address with "set envelope_from=yes".  If I don't do this,
my email is often rejected from mailing lists.

I believe other email clients default to this behavior (see
http://www.mail-archive.com/mutt-users at mutt.org/msg26743.html for the
post I'm basing my assumption on).  Could sup follow that, or at least
allow the option?

I imagine the fix for this would go in edit-message-mode.rb, but my
ruby skills aren't quite there yet.

gsf (a pythonista, mostly)

---

From: [email-masked] (William Morgan)
Date: Wed, 23 Jan 2008 14:12:07 -0800

Reformatted excerpts from Gabriel Sean Farrell's message of 2008-01-23:
> I'm writing this message in mutt instead of sup because I send my
> email via a postfix relay-host and mutt allows me to set my
> Return-Path equal to my "From:" address with "set envelope_from=yes".
> If I don't do this, my email is often rejected from mailing lists.
> 

The Sup way to do this is to have the following line in your
~/.sup/hooks/before-edit.rb:
  header["Return-Path"] = header["From"]

Unfortunately, you have to apply the following patch or Sup simply
discards that header. There's a better solution, which is to make Sup
not discard any headers set by the user when composing email, and I will
take it as a bugfix task to implement that for the next release.

diff --git a/lib/sup/mbox.rb b/lib/sup/mbox.rb
index 0ce52fe..55dd44f 100644
--- a/lib/sup/mbox.rb
+++ b/lib/sup/mbox.rb
@@ -32,6 +32,7 @@ module MBox
         /^(List-Post):\s+(.*?)\s*$/i,
         /^(List-Subscribe):\s+(.*?)\s*$/i,
         /^(List-Unsubscribe):\s+(.*?)\s*$/i,
+        /^(Return-Path):\s+(.*?)\s*$/i,
         /^(Status):\s+(.*?)\s*$/i: header[last = $1] = $2
       when /^(Message-Id):\s+(.*?)\s*$/i: header[mid_field = last = $1] = $2

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

---

From: [email-masked] (Gabriel Sean Farrell)
Date: Wed, 23 Jan 2008 17:47:12 -0500

>        when /^(Message-Id):\s+(.*?)\s*$/i: header[mid_field = last = $1] = $2

I've added the line and applied the patch.  Now I see "Return-Path" in
the headers of my message before I send it, but when I receive it the
return-path is still the one I was trying to override.  Could the one I
set still be getting stripped out?

---

From: [email-masked] (William Morgan)
Date: Thu, 24 Jan 2008 20:03:58 -0800

Reformatted excerpts from Gabriel Sean Farrell's message of 2008-01-23:
> return-path is still the one I was trying to override.  Could the one
> I set still be getting stripped out?

I don't think so... you can apply the patch below and see exactly what
Sup is sending sendmail. In my case, that header is intact. So it must
be getting overwritten somewhere else in the system.

There's some crazy interaction between this header, the From: and
Sender: headers, and the -f option of sendmail. Maybe you should use a
-f with sendmail (in your ~/.sup/config.yaml file)? Did you have a
particular way of calling sendmail with Mutt?

diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mod
index 6a7f273..0e50724 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -279,6 +279,7 @@ protected
       date = Time.now
       m = build_message date
       IO.popen(acct.sendmail, "w") { |p| p.puts m }
+      File.open("sent-copy.txt", "w") { |f| f.puts m }
       raise SendmailCommandFailed, "Couldn't execute #{acct.sendmail}" unless $
       SentManager.write_sent_message(date, from_email) { |f| f.puts sanitize_bo
       BufferManager.kill_buffer buffer

---

From: [email-masked] (Gabriel Sean Farrell)
Date: Fri, 25 Jan 2008 02:50:12 -0500

> particular way of calling sendmail with Mutt?

Right you are about the crazy interaction.  It's not clear to me how
Mutt is calling sendmail, but now I'm guessing all that the "set
envelope_from=yes" does in mutt is add the -f flag followed by one's
"from" email to the call to sendmail.  

If I do that in my ~/.sup/config.yaml, the return-path is set
correctly (at least, it was in my tests.  How does this message
look?!).  In fact, I believe it's set correctly even if I don't set
the return-path in ~/.sup/hooks/edit-before.rb or patch lib/mbox.rb.
In other words, all that needs to be done to fix my problem is the
addition of -f <email> to the sendmail call.  Maybe it could be an
option in the initial account setup?

Oh, and thanks for all the work you're doing on sup, William.  Really
great stuff.

---

From: [email-masked] (Marcus Williams)
Date: Sun, 27 Jan 2008 20:03:54 +0000

> option in the initial account setup?

Even better if this string could written with the to send email as a
variable so you could write something like

"sendmail -f #{m.from}"

... or somehting like that.

Marcus