about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--commands/msg/reply.go25
-rw-r--r--config/config.go3
-rw-r--r--doc/aerc-config.5.scd7
3 files changed, 34 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 {
diff --git a/config/config.go b/config/config.go
index 12096ba..3ae26c1 100644
--- a/config/config.go
+++ b/config/config.go
@@ -75,6 +75,7 @@ type AccountConfig struct {
 	Default         string
 	Postpone        string
 	From            string
+	Aliases         string
 	Name            string
 	Source          string
 	SourceCredCmd   string
@@ -202,6 +203,8 @@ func loadAccountConfig(path string) ([]AccountConfig, error) {
 				account.OutgoingCredCmd = val
 			} else if key == "from" {
 				account.From = val
+			} else if key == "aliases" {
+				account.Aliases = val
 			} else if key == "copy-to" {
 				account.CopyTo = val
 			} else if key == "archive" {
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index fcd70ec..64a0998 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -409,6 +409,13 @@ Note that many of these configuration options are written for you, such as
 
 	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*
 	Specifies the transport for sending outgoing emails on this account.  It
 	should be a connection string, and the specific meaning of each component