summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2016-12-06 14:49:57 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2016-12-06 14:49:57 +0000
commitbee169141788e650cf446ab4fbd3f5fe9f253a2e (patch)
tree15fae8aa3c96553d1ea85dab4faa9c080ae2b578 /alot
parent50cd4588302eb430143144d7b61693c0460be11e (diff)
parent5075dd972049a5eb64be90ba57769d510bcb95a0 (diff)
Merge branch '0.3.8-editnew_bug-819'
Diffstat (limited to 'alot')
-rw-r--r--alot/commands/globals.py79
1 files changed, 39 insertions, 40 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 519cf2aa..af3500ca 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -770,55 +770,54 @@ class ComposeCommand(Command):
self.envelope.add('From', fromaddress)
+ # find out the right account
+ sender = self.envelope.get('From')
+ name, addr = email.Utils.parseaddr(sender)
+ account = settings.get_account_by_address(addr)
+ if account is None:
+ accounts = settings.get_accounts()
+ if not accounts:
+ ui.notify('no accounts set.', priority='error')
+ return
+ account = accounts[0]
+
# add signature
- if not self.omit_signature:
- name, addr = email.Utils.parseaddr(self.envelope['From'])
- account = settings.get_account_by_address(addr)
- if account is not None:
- if account.signature:
- logging.debug('has signature')
- sig = os.path.expanduser(account.signature)
- if os.path.isfile(sig):
- logging.debug('is file')
- if account.signature_as_attachment:
- name = account.signature_filename or None
- self.envelope.attach(sig, filename=name)
- logging.debug('attached')
- else:
- sigcontent = open(sig).read()
- enc = helper.guess_encoding(sigcontent)
- mimetype = helper.guess_mimetype(sigcontent)
- if mimetype.startswith('text'):
- sigcontent = helper.string_decode(sigcontent,
- enc)
- self.envelope.body += '\n' + sigcontent
- else:
- ui.notify('could not locate signature: %s' % sig,
- priority='error')
- if (yield ui.choice('send without signature?', 'yes',
- 'no')) == 'no':
- return
+ if not self.omit_signature and account.signature:
+ logging.debug('has signature')
+ sig = os.path.expanduser(account.signature)
+ if os.path.isfile(sig):
+ logging.debug('is file')
+ if account.signature_as_attachment:
+ name = account.signature_filename or None
+ self.envelope.attach(sig, filename=name)
+ logging.debug('attached')
+ else:
+ sigcontent = open(sig).read()
+ enc = helper.guess_encoding(sigcontent)
+ mimetype = helper.guess_mimetype(sigcontent)
+ if mimetype.startswith('text'):
+ sigcontent = helper.string_decode(sigcontent, enc)
+ self.envelope.body += '\n' + sigcontent
+ else:
+ ui.notify('could not locate signature: %s' % sig,
+ priority='error')
+ if (yield ui.choice('send without signature?', 'yes',
+ 'no')) == 'no':
+ return
# Figure out whether we should GPG sign messages by default
# and look up key if so
- sender = self.envelope.get('From')
- name, addr = email.Utils.parseaddr(sender)
- account = settings.get_account_by_address(addr)
- if account:
- self.envelope.sign = account.sign_by_default
- self.envelope.sign_key = account.gpg_key
+ self.envelope.sign = account.sign_by_default
+ self.envelope.sign_key = account.gpg_key
# get missing To header
if 'To' not in self.envelope.headers:
allbooks = not settings.get('complete_matching_abook_only')
logging.debug(allbooks)
- if account is not None:
- abooks = settings.get_addressbooks(order=[account],
- append_remaining=allbooks)
- logging.debug(abooks)
- completer = ContactsCompleter(abooks)
- else:
- completer = None
+ abooks = settings.get_addressbooks(order=[account],
+ append_remaining=allbooks)
+ logging.debug(abooks)
+ completer = ContactsCompleter(abooks)
to = yield ui.prompt('To',
completer=completer)
if to is None: