fix!: sending from wrong email (#199) (#200)

Drew Smirnoff created

Change summary

sender/sender.go     | 6 +++---
tui/composer.go      | 6 +++---
tui/composer_test.go | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)

Detailed changes

sender/sender.go 🔗

@@ -37,9 +37,9 @@ func SendEmail(account *config.Account, to, cc, bcc []string, subject, plainBody
 
 	auth := smtp.PlainAuth("", account.Email, account.Password, smtpServer)
 
-	fromHeader := account.Email
+	fromHeader := account.FetchEmail
 	if account.Name != "" {
-		fromHeader = fmt.Sprintf("%s <%s>", account.Name, account.Email)
+		fromHeader = fmt.Sprintf("%s <%s>", account.Name, account.FetchEmail)
 	}
 
 	// Main message buffer
@@ -52,7 +52,7 @@ func SendEmail(account *config.Account, to, cc, bcc []string, subject, plainBody
 		"To":           strings.Join(to, ", "),
 		"Subject":      subject,
 		"Date":         time.Now().Format(time.RFC1123Z),
-		"Message-ID":   generateMessageID(account.Email),
+		"Message-ID":   generateMessageID(account.FetchEmail),
 		"Content-Type": "multipart/mixed; boundary=" + mainWriter.Boundary(),
 	}
 

tui/composer.go 🔗

@@ -166,9 +166,9 @@ func (m *Composer) getFromAddress() string {
 	if len(m.accounts) > 0 && m.selectedAccountIdx < len(m.accounts) {
 		acc := m.accounts[m.selectedAccountIdx]
 		if acc.Name != "" {
-			return fmt.Sprintf("%s <%s>", acc.Name, acc.Email)
+			return fmt.Sprintf("%s <%s>", acc.Name, acc.FetchEmail)
 		}
-		return acc.Email
+		return acc.FetchEmail
 	}
 	return ""
 }
@@ -479,7 +479,7 @@ func (m *Composer) View() string {
 		var accountList strings.Builder
 		accountList.WriteString("Select Account:\n\n")
 		for i, acc := range m.accounts {
-			display := acc.Email
+			display := acc.FetchEmail
 			if acc.Name != "" {
 				display = fmt.Sprintf("%s (%s)", acc.Name, acc.FetchEmail)
 			}

tui/composer_test.go 🔗

@@ -220,7 +220,7 @@ func TestComposerUpdate(t *testing.T) {
 func TestComposerGetFromAddress(t *testing.T) {
 	t.Run("With name", func(t *testing.T) {
 		accounts := []config.Account{
-			{ID: "account-1", Email: "test@example.com", Name: "Test User"},
+			{ID: "account-1", FetchEmail: "test@example.com", Name: "Test User"},
 		}
 		composer := NewComposerWithAccounts(accounts, "account-1", "", "", "")
 
@@ -233,7 +233,7 @@ func TestComposerGetFromAddress(t *testing.T) {
 
 	t.Run("Without name", func(t *testing.T) {
 		accounts := []config.Account{
-			{ID: "account-1", Email: "test@example.com"},
+			{ID: "account-1", FetchEmail: "test@example.com"},
 		}
 		composer := NewComposerWithAccounts(accounts, "account-1", "", "", "")