Marianne
2009-Jan-06 14:49 UTC
[sup-talk] questions about reply-from & before-edit hooks and accounts
Hi, I''m now successfully using two hooks to use my sup-talk specific e-mail address for mail to this list: reply-from.rb: PersonManager.person_for case when message.recipient_email =~ /rubyforge/ "my.name+sup-talk at gmail.com" end before-edit.rb: if header["To"] =~ /rubyforge/ header["From"] = "Marianne <my.name+sup-talk at gmail.com>" end It seems that the "Person" returned by the reply-from hook matches to some extent, but not completely, an account in my ~/.sup/config.yaml, where I have a :sup-talk: section with its own e-mail, sendmail, and signature. The hook picks not just the correct e-mail, but also the corresponding sendmail, but not the signature of that section. For before-edit.rb, I have found no way to switch the signature and sendmail along with the "from" address. I know there is a signature hook which I could use for the first, but how to do the latter. Maybe I''m missing something, but ideally, I''d love to see something where I could define different accounts in the config.yaml, then have a way that works both for replying and for new mail to pick *all* settings of that account from config.yaml. An additional question: For friends & family recipients, I''d like to use my private settings. I maintain a list of such e-mail addresses in an external text file, and I think that''s neater than listing them all in each hook when needed. In before-add-message.rb, I use this: privatfile = File.open("/home/mpromber/.mutt/privataddr","r") if ! privatfile.grep(/#{message.from.email}/).empty? message.add_label :privat end but it seems "message.from.email" is not available for before-edit.rb. I''m currently using this as a workaround: privatfile = File.open("/home/mpromber/.mutt/privataddr","r") toaddr = header["To"].scan(/[a-z0-9+._-]+@[a-z0-9.-]+\.[a-z]{2,4}/).join(sep="") regexaddr = "^" + toaddr + "$" if ! privatfile.grep(/#{regexaddr}/).empty? header["From"] = "Marianne <myprivate at address.com>" end Is there an easier mail to access the recipient e-mail address? And I also guess I have to rewrite this to handle the case of several recipients, which definitely would be easier if there''s already and array of recipient addresses I can refer to. Thanks, Marianne -- Marianne Promberger PGP/GnuPG public key ID 80AD9916
Marcus Williams
2009-Jan-06 20:13 UTC
[sup-talk] questions about reply-from & before-edit hooks and accounts
On 6.1.2009, marianne.promberger+sup-talk wrote:> reply-from.rb: > > PersonManager.person_for case > when message.recipient_email =~ /rubyforge/ > "my.name+sup-talk at gmail.com" > end > before-edit.rb: > > if header["To"] =~ /rubyforge/ > header["From"] = "Marianne <my.name+sup-talk at gmail.com>" > end[snip]> Maybe I''m missing something, but ideally, I''d love to see something where I > could define different accounts in the config.yaml, then have a way that works > both for replying and for new mail to pick *all* settings of that account from > config.yaml.You might want to look through the archives for the regexen option - I use it for this purpose (although it only solves your reply-to case). Add something like :regexen: - my.name+.*@gmail.com to your settings on an account (you can use regexes here and have more than one if you want, but the one above will work in your case). This allows sup to recognise your mail "aliases" and replies to incoming mails addressed to these emails with the correct from address automagically. It wont help for mails you compose (ie "new" mails, not replies), but it works well for replies. HTH Marcus
Marianne
2009-Jan-14 18:34 UTC
[sup-talk] questions about reply-from & before-edit hooks and accounts
Excerpts from Marcus Williams''s message of Tue Jan 06 20:13:53 +0000 2009:> > You might want to look through the archives for the regexen option - I > use it for this purpose (although it only solves your reply-to case). >Thanks for that tip. I''ve tried it and it works, although as you note it only works for replying. For me, it also unfortunately does not set my name to the :name: set in that account, but instead uses the part of the e-mail in front of the "@" as my name. However, I have to correct myself when I wrote that picking a person with the reply-from.rb doesn''t pick the correct sig from that account. While I still think I tested this and it didn''t work, this is now the second post to sup-talk where sup picks the correct sig from my sup-talk account in config.yaml. So that''s great; I just miss being able to handle this in before-edit.rb in a similar way as in reply-from.rb, i.e, by having access to things like "message.recipient_email", and return a person from config.yaml Sorry for all the nagging, I know sup is beta. Take it as a compliment that sup has so many nice features that it raises the standards to which it will be held :) Marianne