Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for storing sent mails per account. #506

Closed
wants to merge 1 commit into from

Conversation

spacefrogg
Copy link

• Remain backwards compatible by adding a source with id 9998
to the sup://sent standard mbox
• Add new YAML keyword :sent_source: to accounts
• Code cleanups due to the new handling of sent sources

Should fix #255 and #395.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
 • Remain backwards compatible by adding a source with id 9998
   to the sup:/sent standard mbox
 • Add new YAML keyword :sent_source: to accounts
 • Code cleanups due to the new handling of sent sources
@joWeiss
Copy link

joWeiss commented Feb 4, 2016

I would be really happy to see this feature in the main version.
Is there a way to help development even if I don't really know Ruby?

@gauteh
Copy link
Member

gauteh commented Feb 4, 2016

Jonas Weissensel writes on February 4, 2016 16:35:

I would be really happy to see this feature in the main version.
Is there a way to help development even if I don't really know Ruby?

You can test it and report whether it works or if there are any
problems.

@pwnage101
Copy link

@spacefrogg I found a bug in this PR, but I didn't want to start up a new PR so I'll just paste the diff below. Basically, you need to correctly handle the case where the sent_source for an account is inherited from the default account.

diff --git a/lib/sup/account.rb b/lib/sup/account.rb
index 4916950..f1731ab 100644
--- a/lib/sup/account.rb
+++ b/lib/sup/account.rb
@@ -11,12 +11,7 @@ class Account < Person
     @sendmail = h[:sendmail]
     @signature = h[:signature]
     @gpgkey = h[:gpgkey]
-    begin
-      try_source = h[:sent_source] || $config[:sent_source] || fail
-      @sent_source = SourceManager.source_for(try_source) || fail
-    rescue
-      raise FatalSourceError, "'#{try_source}' is not a valid sent source for account #{h[:email]}"
-    end
+    @sent_source = h[:sent_source]
     debug "sent source for #{h[:email]} is #{@sent_source.uri}" if @sent_source
   end

@@ -54,9 +49,19 @@ class AccountManager
   ## values from the default account.
   def add_account hash, default=false
     raise ArgumentError, "no email specified for account" unless hash[:email]
+    custom_sent_source = hash.has_key? :sent_source
     unless default
       [:name, :sendmail, :signature, :gpgkey, :sent_source].each { |k| hash[k] ||= @default_account.send(k) }
     end
+    if default or custom_sent_source
+      # get actual source object from the custom sent_source string
+      begin
+        try_source = hash[:sent_source] || $config[:sent_source] || fail
+        hash[:sent_source] = SourceManager.source_for(try_source) || fail
+      rescue
+        raise FatalSourceError, "'#{try_source}' is not a valid sent source for account #{h[:email]}. sources: #{SourceManager.sources}"
+      end
+    end
     hash[:alternates] ||= []
     fail "alternative emails are not an array: #{hash[:alternates]}" unless hash[:alternates].kind_of? Array

With this patch, all I needed to do was add a :sent_source key to a few of my accounts, and it worked out of the box! Example account with a custom sent_source:

  :example:
    :name: Jonh Doe
    :email: [email protected]
    :sent_source: maildir:/home/jdoe/mail/example/sent

@spacefrogg
Copy link
Author

Nice, thank you! Please commit on top of my branch and I will update the pull request. I personally have moved on to another mail client but would be happy to update the PR.

@spacefrogg
Copy link
Author

Closing this PR due to inactivity

@spacefrogg spacefrogg closed this Mar 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

option to add a sent source in sup-config
4 participants