File schleuder_keep_to_cc.patch of Package rubygem-schleuder
Index: schleuder-4.0.2/db/migrate/20210608124308_add_keep_incoming_cc.rb
===================================================================
--- /dev/null
+++ schleuder-4.0.2/db/migrate/20210608124308_add_keep_incoming_cc.rb
@@ -0,0 +1,11 @@
+class AddKeepIncomingCc < ActiveRecord::Migration[4.2]
+ def up
+ if ! column_exists?(:lists, :keep_incoming_cc)
+ add_column :lists, :keep_incoming_cc, :boolean, default: false
+ end
+ end
+
+ def down
+ remove_column(:lists, :keep_incoming_cc)
+ end
+end
Index: schleuder-4.0.2/db/migrate/20210608124309_add_keep_incoming_to.rb
===================================================================
--- /dev/null
+++ schleuder-4.0.2/db/migrate/20210608124309_add_keep_incoming_to.rb
@@ -0,0 +1,11 @@
+class AddKeepIncomingTo < ActiveRecord::Migration[4.2]
+ def up
+ if ! column_exists?(:lists, :keep_incoming_to)
+ add_column :lists, :keep_incoming_to, :boolean, default: false
+ end
+ end
+
+ def down
+ remove_column(:lists, :keep_incoming_to)
+ end
+end
Index: schleuder-4.0.2/db/schema.rb
===================================================================
--- schleuder-4.0.2.orig/db/schema.rb
+++ schleuder-4.0.2/db/schema.rb
@@ -47,6 +47,8 @@ ActiveRecord::Schema.define(version: 202
t.boolean "include_autocrypt_header", default: true
t.boolean "set_reply_to_to_sender", default: false
t.boolean "munge_from", default: false
+ t.boolean "keep_incoming_cc", default: false
+ t.boolean "keep_incoming_to", default: false
end
create_table "subscriptions", force: :cascade do |t|
Index: schleuder-4.0.2/etc/list-defaults.yml
===================================================================
--- schleuder-4.0.2.orig/etc/list-defaults.yml
+++ schleuder-4.0.2/etc/list-defaults.yml
@@ -149,3 +149,19 @@ set_reply_to_to_sender: false
# This option can enabled for improved usability since this affect
# mail client's displayed name.
munge_from: false
+
+# Keep "To" header of incoming mail?
+# Enabling this option will set the "To" header of the mails distributed by schleuder
+# to the "To" header of the incoming mail. This allows recipients to see the original
+# mail's "To" addresses and their MUA to use those addresses when using "Reply-All".
+# Warning: This means, that the addresses in the "To" header of the incoming mail
+# are transmitted unencrypted in the headers of the email.
+keep_incoming_to: false
+
+# Keep "CC" header of incoming mail?
+# Enabling this option will set the "CC" header of the mails distributed by schleuder
+# to the "CC" header of the incoming mail. This allows recipients to see the original
+# mail's "CC" addresses and their MUA to use those addresses when using "Reply-All".
+# Warning: This means, that the addresses in the "CC" header of the incoming mail
+# are transmitted unencrypted in the headers of the email.
+keep_incoming_cc: false
Index: schleuder-4.0.2/lib/schleuder/list.rb
===================================================================
--- schleuder-4.0.2.orig/lib/schleuder/list.rb
+++ schleuder-4.0.2/lib/schleuder/list.rb
@@ -82,6 +82,15 @@ module Schleuder
# The default is off.
validates :munge_from, boolean: true
+ # Many users use the "cc" function of an email. When set to true, this passes through the original
+ # "cc" header, so mail clients can easily click on "Reply-To" and their client will have the "cc"
+ # set to all "cc" addresses from the original email as new "cc" header.
+ validates :keep_incoming_cc, boolean: true
+
+ # Some users write emails with more than one address in the "to" header. When set to true, this passes through the
+ # original "to" header, so mail clients receiving the mail from schleuder can easily click on "Reply-To"
+ # and their client will set all "to" addresses from the original email to the new "to" header.
+ validates :keep_incoming_to, boolean: true
default_scope { order(:email) }
Index: schleuder-4.0.2/lib/schleuder/mail/gpg.rb
===================================================================
--- schleuder-4.0.2.orig/lib/schleuder/mail/gpg.rb
+++ schleuder-4.0.2/lib/schleuder/mail/gpg.rb
@@ -8,6 +8,16 @@ module Mail
if cleartext_mail.protected_headers_subject
encrypted_mail.subject = cleartext_mail.protected_headers_subject
end
+
+ # The original "mail-gpg" gem does not handle the smtp envelope correctly
+ # as it always sets the envelope "RCPT TO" to all addresses from the To, CC and BCC header.
+ # This is a problem for the options keep_incoming_to and keep_incoming_cc as
+ # we need the headers for the mail clients to display the original to and cc but only
+ # send to one recipient on the list per mail. Thus we overwrite this setting here.
+ if cleartext_mail.smtp_envelope_to
+ encrypted_mail.smtp_envelope_to = cleartext_mail.smtp_envelope_to
+ end
+
encrypted_mail
end
end
Index: schleuder-4.0.2/lib/schleuder/mail/gpg/encrypted_part.rb
===================================================================
--- schleuder-4.0.2.orig/lib/schleuder/mail/gpg/encrypted_part.rb
+++ schleuder-4.0.2/lib/schleuder/mail/gpg/encrypted_part.rb
@@ -7,6 +7,14 @@ module Mail
if cleartext_mail.protected_headers_subject
cleartext_mail.content_type_parameters['protected-headers'] = 'v1'
end
+
+ # The original "mail-gpg" gem does not handle the smtp envelope correctly
+ # as it always sets the envelope "RCPT TO" to all addresses from the To, CC and BCC header.
+ # This overwrites the recipients used by "mail-gpg" to the envelope To.
+ if cleartext_mail.smtp_envelope_to
+ options[:recipients] = cleartext_mail.smtp_envelope_to
+ end
+
initialize_mailgpg(cleartext_mail, options)
end
end
Index: schleuder-4.0.2/lib/schleuder/subscription.rb
===================================================================
--- schleuder-4.0.2.orig/lib/schleuder/subscription.rb
+++ schleuder-4.0.2/lib/schleuder/subscription.rb
@@ -67,12 +67,34 @@ module Schleuder
list.logger.info "Sending message to #{self.email}"
mail.gpg gpg_opts
+
+ # allows different envelope "to" from header "to+cc+bcc"
+ # needed for options keep_incoming_to and keep_incoming_cc
+ mail.smtp_envelope_to = self.email
+
mail.deliver
end
def ensure_headers(mail, incoming_mail=nil)
mail.to = self.email
-
+
+ if self.list.keep_incoming_to? && ! incoming_mail.nil?
+ # If option is set to true, the to-header of the mail will be set to the original to-header of the incoming mail.
+ # So the original to-header is "passed through".
+ # This enables mail clients to parse the original headers and thus provides a working "reply-all" in the mail client when
+ # the user provided two or more addresses in the to-header.
+ # e.g. original mail's to-header: `To: schleuder-list@example.com, person1@example.com`
+ mail.to = incoming_mail.to
+ end
+
+ if self.list.keep_incoming_cc? && ! incoming_mail.nil?
+ # If option is set to true, the cc-header of the mail will be set to the original cc-header of the incoming mail.
+ # So the original cc-header is "passed through".
+ # This enables mail clients to parse the original headers and thus provides a working "reply-all" in the mail client when
+ # the user provided addresses in the cc-header.
+ mail.cc = incoming_mail.cc
+ end
+
if self.list.set_reply_to_to_sender? && ! incoming_mail.nil?
# If the option "set_reply_to_to_sender" is set to true, we will set the reply-to header
# to the reply-to header given by the original email. If no reply-to header exists in the original email,