about summary refs log tree commit diff stats
path: root/commands/compose/send.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/compose/send.go')
-rw-r--r--commands/compose/send.go50
1 files changed, 27 insertions, 23 deletions
diff --git a/commands/compose/send.go b/commands/compose/send.go
index 122391b..ee0c4ad 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -84,6 +84,12 @@ func SendMessage(aerc *widgets.Aerc, args []string) error {
 
 	aerc.RemoveTab(composer)
 
+	fmt.Println(config.Params)
+	var starttls bool
+	if starttls_, ok := config.Params["smtp-starttls"]; ok {
+		starttls = starttls_ == "yes"
+	}
+
 	sendAsync := func() (int, error) {
 		tlsConfig := &tls.Config{
 			// TODO: ask user first
@@ -97,17 +103,25 @@ func SendMessage(aerc *widgets.Aerc, args []string) error {
 			}
 			conn, err = smtp.Dial(host)
 			if err != nil {
-				aerc.PushStatus(" "+err.Error(), 10*time.Second).
-					Color(tcell.ColorDefault, tcell.ColorRed)
-				return 0, nil
+				return 0, err
 			}
 			defer conn.Close()
 			if sup, _ := conn.Extension("STARTTLS"); sup {
-				// TODO: let user configure tls?
+				if !starttls {
+					err := errors.New("STARTTLS is supported by this server, " +
+						"but not set in accounts.conf. " +
+						"Add smtp-starttls=yes")
+					return 0, err
+				}
 				if err = conn.StartTLS(tlsConfig); err != nil {
-					aerc.PushStatus(" "+err.Error(), 10*time.Second).
-						Color(tcell.ColorDefault, tcell.ColorRed)
-					return 0, nil
+					return 0, err
+				}
+			} else {
+				if starttls {
+					err := errors.New("STARTTLS requested, but not supported " +
+						"by this SMTP server. Is someone tampering with your " +
+						"connection?")
+					return 0, err
 				}
 			}
 		case "smtps":
@@ -117,9 +131,7 @@ func SendMessage(aerc *widgets.Aerc, args []string) error {
 			}
 			conn, err = smtp.DialTLS(host, tlsConfig)
 			if err != nil {
-				aerc.PushStatus(" "+err.Error(), 10*time.Second).
-					Color(tcell.ColorDefault, tcell.ColorRed)
-				return 0, nil
+				return 0, err
 			}
 			defer conn.Close()
 		}
@@ -127,29 +139,21 @@ func SendMessage(aerc *widgets.Aerc, args []string) error {
 		// TODO: sendmail
 		if saslClient != nil {
 			if err = conn.Auth(saslClient); err != nil {
-				aerc.PushStatus(" "+err.Error(), 10*time.Second).
-					Color(tcell.ColorDefault, tcell.ColorRed)
-				return 0, nil
+				return 0, err
 			}
 		}
 		// TODO: the user could conceivably want to use a different From and sender
 		if err = conn.Mail(from.Address); err != nil {
-			aerc.PushStatus(" "+err.Error(), 10*time.Second).
-				Color(tcell.ColorDefault, tcell.ColorRed)
-			return 0, nil
+			return 0, err
 		}
 		for _, rcpt := range rcpts {
 			if err = conn.Rcpt(rcpt); err != nil {
-				aerc.PushStatus(" "+err.Error(), 10*time.Second).
-					Color(tcell.ColorDefault, tcell.ColorRed)
-				return 0, nil
+				return 0, err
 			}
 		}
 		wc, err := conn.Data()
 		if err != nil {
-			aerc.PushStatus(" "+err.Error(), 10*time.Second).
-				Color(tcell.ColorDefault, tcell.ColorRed)
-			return 0, nil
+			return 0, err
 		}
 		defer wc.Close()
 		ctr := datacounter.NewWriterCounter(wc)
@@ -161,7 +165,7 @@ func SendMessage(aerc *widgets.Aerc, args []string) error {
 		aerc.SetStatus("Sending...")
 		nbytes, err := sendAsync()
 		if err != nil {
-			aerc.PushStatus(" "+err.Error(), 10*time.Second).
+			aerc.SetStatus(" "+err.Error()).
 				Color(tcell.ColorDefault, tcell.ColorRed)
 			return
 		}
an class='oid'>cdbc84b ^
84432e6 ^
338c083 ^

84432e6 ^

1a25414 ^

b439892 ^
caf5a16 ^
901b3ed ^
1076f2b

901b3ed ^
0c3544d ^
2b35fae ^

a3e3f0b ^

2b35fae ^
3e06ede ^
cdbc84b ^
338c083 ^
292ccc4 ^
d4b7a9a ^
10885d3 ^
1836b67 ^
ee8fb0c ^
7ab8c87 ^
1836b67 ^
ee8fb0c ^
7ab8c87 ^
2b35fae ^
72655f0 ^
ee8fb0c ^
df74b26 ^
0ea0343 ^
72655f0 ^
ee8fb0c ^
5871008 ^
cb9607c ^
0b5c14c ^


fef6c5c ^


aa53e39 ^


ee8fb0c ^
7ab8c87 ^
72655f0 ^
ee8fb0c ^
7ab8c87 ^
3af6434 ^
85c9ebf ^
aa53e39 ^
9066ee2 ^
ee8fb0c ^
08c2d92 ^
352cae4 ^
ee8fb0c ^
1549faf ^
7ab8c87 ^

1549faf ^
ee8fb0c ^
42fd392 ^

ee8fb0c ^
df74b26 ^
7ab8c87 ^

df74b26 ^
ee8fb0c ^
7ab8c87 ^
45aea23 ^
ee8fb0c ^
338c083 ^
1549faf ^
ee8fb0c ^
a92cf49 ^
8dc8605 ^
ee8fb0c ^
df74b26 ^
7ab8c87 ^

1549faf ^
ee8fb0c ^
7ab8c87 ^
daae3bb ^
ee8fb0c ^
3e06ede ^
7ab8c87 ^

4bb89e2 ^
ee8fb0c ^
7ab8c87 ^
2b35fae ^
0c3544d ^
ee8fb0c ^
d1ce3ea ^
0e5c819 ^
ee8fb0c ^
b2f276b ^
4bd0d33 ^
ee8fb0c ^
d1ce3ea ^
0c3544d ^
7ab8c87 ^
dc5c070 ^
7e98db2 ^

bced907 ^
60b3dce ^
21bd90d ^
c8f96b5 ^
4bb89e2 ^
c8f96b5 ^



c7da124 ^


c8f96b5 ^

124866e ^







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156