[Users] automatically changing From address

Barry Warsaw barry at python.org
Sun Jun 4 00:30:21 CEST 2017

I have some Python scripts that I've been using for ages to do this, across
all my email addresses (yes, I do the same thing as you, but also have many
FLOSS project addresses).

This is a rough outline; the details are suppressed.  Put this in
~/.claws-mail/python-scripts/auto/compose_any and season to taste.

-----snip snip-----
from email.utils import parseaddr

DOT = '.'

for header, value in clawsmail.compose_window.get_header_list():
    header = header.lower()
    choice = None
    if header in ('to:', 'cc:'):
        realname, email = parseaddr(value.lower())
        local, at, domain = email.partition('@')
        superdomain = DOT.join(domain.split(DOT)[1:])
        organization = DOT.join(domain.split(DOT)[-2:])
        # Now you can test 'local', 'domain', 'superdomain', and
        # 'organization' with whatever conditionals you want, e.g.
        if domain == 'example.com':
            choice = 'foo at example.com'
        # ...
        if choice is not None:
-----snip snip-----


On May 24, 2017, at 12:59 PM, Dave Howorth wrote:

>I get all the mail sent to my domain, and frequently use unique mail
>addresses when communicating with firms (e.g. I might have subscribed
>here using claws-mail at howorth.org.uk). When they send me mail, they do
>so to these unique addresses, but if I reply to the mail it is sent
>from my main address. I'd like it to be sent from the unique address
>instead. Presently I do this by editing the From line manually, but is
>it possible to do this automatically? i.e. Use the To address as the
>From address when replying to mail?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.claws-mail.org/pipermail/users/attachments/20170603/046b0328/attachment.sig>

More information about the Users mailing list