about summary refs log tree commit diff stats
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/msg/reply.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 7181e1e..8cca2b1 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -64,6 +64,10 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
 	if err != nil {
 		return err
 	}
+	alias_of_us, err := format.ParseAddressList(conf.Aliases)
+	if err != nil {
+		return err
+	}
 	store := widget.Store()
 	if store == nil {
 		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 {
 		return err
 	}
-	acct.Logger().Println("Replying to email " + msg.Envelope.MessageId)
 
 	var (
 		to []*models.Address
@@ -84,6 +87,26 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
 		} else {
 			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 {
 			for _, ta := range to {
 				if ta.Address == a.Address {