Add account alias configuration and correctly set From field
We infer the correct From using the To: and Cc: field of the email that we reply to.
This commit is contained in:
parent
2a186cfd71
commit
6a1c0f60af
3 changed files with 34 additions and 1 deletions
|
@ -64,6 +64,10 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
alias_of_us, err := format.ParseAddressList(conf.Aliases)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
store := widget.Store()
|
store := widget.Store()
|
||||||
if store == nil {
|
if store == nil {
|
||||||
return errors.New("Cannot perform action. Messages still loading")
|
return errors.New("Cannot perform action. Messages still loading")
|
||||||
|
@ -72,7 +76,6 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
acct.Logger().Println("Replying to email " + msg.Envelope.MessageId)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
to []*models.Address
|
to []*models.Address
|
||||||
|
@ -84,6 +87,26 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
} else {
|
} else {
|
||||||
to = msg.Envelope.From
|
to = msg.Envelope.From
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// figure out the sending from address if we have aliases
|
||||||
|
if len(alias_of_us) != 0 {
|
||||||
|
allRecipients := append(msg.Envelope.To, msg.Envelope.Cc...)
|
||||||
|
outer:
|
||||||
|
for _, addr := range allRecipients {
|
||||||
|
if addr.Address == from.Address {
|
||||||
|
from = addr
|
||||||
|
break
|
||||||
|
}
|
||||||
|
for _, alias := range alias_of_us {
|
||||||
|
if addr.Address == alias.Address {
|
||||||
|
from = addr
|
||||||
|
break outer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
isMainRecipient := func(a *models.Address) bool {
|
isMainRecipient := func(a *models.Address) bool {
|
||||||
for _, ta := range to {
|
for _, ta := range to {
|
||||||
if ta.Address == a.Address {
|
if ta.Address == a.Address {
|
||||||
|
|
|
@ -75,6 +75,7 @@ type AccountConfig struct {
|
||||||
Default string
|
Default string
|
||||||
Postpone string
|
Postpone string
|
||||||
From string
|
From string
|
||||||
|
Aliases string
|
||||||
Name string
|
Name string
|
||||||
Source string
|
Source string
|
||||||
SourceCredCmd string
|
SourceCredCmd string
|
||||||
|
@ -202,6 +203,8 @@ func loadAccountConfig(path string) ([]AccountConfig, error) {
|
||||||
account.OutgoingCredCmd = val
|
account.OutgoingCredCmd = val
|
||||||
} else if key == "from" {
|
} else if key == "from" {
|
||||||
account.From = val
|
account.From = val
|
||||||
|
} else if key == "aliases" {
|
||||||
|
account.Aliases = val
|
||||||
} else if key == "copy-to" {
|
} else if key == "copy-to" {
|
||||||
account.CopyTo = val
|
account.CopyTo = val
|
||||||
} else if key == "archive" {
|
} else if key == "archive" {
|
||||||
|
|
|
@ -409,6 +409,13 @@ Note that many of these configuration options are written for you, such as
|
||||||
|
|
||||||
Default: none
|
Default: none
|
||||||
|
|
||||||
|
*aliases*
|
||||||
|
All aliases of the current account. These will be used to fill in the From:
|
||||||
|
field. Make sure that your email server accepts this value, or for example
|
||||||
|
use *aerc-sendmail*(5) in combination with msmtp and --read-envelope-from.
|
||||||
|
|
||||||
|
Default: none
|
||||||
|
|
||||||
*outgoing*
|
*outgoing*
|
||||||
Specifies the transport for sending outgoing emails on this account. It
|
Specifies the transport for sending outgoing emails on this account. It
|
||||||
should be a connection string, and the specific meaning of each component
|
should be a connection string, and the specific meaning of each component
|
||||||
|
|
Loading…
Reference in a new issue