This is the main dovel repository, it has the Go code to run dovel SMTP server.
Author: x (x@mail.blmayer.dev)
Date: Mon Jun 19 16:15:53 2023 -0300
Parent: 9edf311
Adjusted dark theme * Improved pgp key
commit a9e372185ed0569226ff1399a3bb30e57d0808b7
Author: x <x@mail.blmayer.dev>
Date: Mon Jun 19 16:15:53 2023 -0300
Adjusted dark theme
* Improved pgp key
diff --git a/cmd/dovel/web.go b/cmd/dovel/web.go
index 56ad76f..a1121aa 100644
--- a/cmd/dovel/web.go
+++ b/cmd/dovel/web.go
@@ -124,12 +124,12 @@ func (h webHandler) sendHandler() http.HandlerFunc {
fo := r.MultipartForm
email := interfaces.Email{
- From: fo.Value["from"][0],
+ From: fo.Get("from"),
To: fo.Value["to"],
Cc: fo.Value["cc"],
- Subject: fo.Value["subject"][0],
+ Subject: fo.Get("subject"),
Date: time.Now(),
- Body: fo.Value["body"][0],
+ Body: fo.Get("body"),
Attachments: map[string]interfaces.Attachment{},
}
@@ -153,12 +153,11 @@ func (h webHandler) sendHandler() http.HandlerFunc {
}
}
- var key crypto.PublicKey
- if len(fo.Value["key"]) > 0 {
- key = crypto.BLAKE2b_256
+ opts := interfaces.Opt{
+ Key: fo.Get("key"),
+ Encrypt: fo.Get("encrypt") != "",
}
-
- err := h.mailer.Send(email, key)
+ err := h.mailer.Send(email, opts)
if err != nil {
println("send error: " + err.Error())
http.Error(w, "send error"+err.Error(), http.StatusInternalServerError)
commit a9e372185ed0569226ff1399a3bb30e57d0808b7
Author: x <x@mail.blmayer.dev>
Date: Mon Jun 19 16:15:53 2023 -0300
Adjusted dark theme
* Improved pgp key
diff --git a/interfaces/file/file.go b/interfaces/file/file.go
index 30024e5..556489e 100644
--- a/interfaces/file/file.go
+++ b/interfaces/file/file.go
@@ -155,26 +155,28 @@ func (f FileHandler) Send(mail interfaces.Email, opts interfaces.Opt) error {
return err
}
- // grab public key if wanted
if opts.Encrypt {
- key, err := wkd.FetchPGPKey(addr[0], addr[1])
+ text, err := form.CreatePart(
+ map[string][]string{
+ "Content-Type": {"application/pgp-encrypted"},
+ },
+ )
if err != nil {
- println("error fetching key", err)
- } else {
- text, err := form.CreatePart(
- map[string][]string{
- "Content-Type": {"application/pgp-encrypted"},
- },
- )
- if err != nil {
- return err
- }
- cypher, err := helper.EncryptMessageArmored(key, mail.Body)
+ return err
+ }
+
+ // grab public key if wanted
+ if opts.Key == "" {
+ opts.Key, err = wkd.FetchPGPKey(addr[0], addr[1])
if err != nil {
return err
}
- text.Write([]byte(cypher))
}
+ cypher, err := helper.EncryptMessageArmored(opts.Key, mail.Body)
+ if err != nil {
+ return err
+ }
+ text.Write([]byte(cypher))
} else {
text, err := form.CreatePart(
map[string][]string{
commit a9e372185ed0569226ff1399a3bb30e57d0808b7
Author: x <x@mail.blmayer.dev>
Date: Mon Jun 19 16:15:53 2023 -0300
Adjusted dark theme
* Improved pgp key
diff --git a/interfaces/gwi/gwi.go b/interfaces/gwi/gwi.go
index b26e8c7..417a45e 100644
--- a/interfaces/gwi/gwi.go
+++ b/interfaces/gwi/gwi.go
@@ -143,7 +143,7 @@ The GWI team.`,
return g.Send(email)
}
-func (g GWIHandler) Send(mail interfaces.Email) error {
+func (g GWIHandler) Send(mail interfaces.Email, opts interfaces.Opt) error {
mail.ID = fmt.Sprintf("%d@%s", mail.Date.Unix(), g.domain)
body := bytes.Buffer{}
commit a9e372185ed0569226ff1399a3bb30e57d0808b7
Author: x <x@mail.blmayer.dev>
Date: Mon Jun 19 16:15:53 2023 -0300
Adjusted dark theme
* Improved pgp key
diff --git a/interfaces/main.go b/interfaces/main.go
index 6cee223..ad6713b 100644
--- a/interfaces/main.go
+++ b/interfaces/main.go
@@ -62,6 +62,7 @@ type Attachment struct {
type Opt struct {
Encrypt bool
+ Key string
}
type Email struct {
@@ -114,7 +115,7 @@ func ToEmail(mail parsemail.Email) Email {
}
type Mailer interface {
- Send(mail Email) error
+ Send(mail Email, opts Opt) error
Save(mail Email) error
Mailboxes(folder string) ([]Mailbox, error)
Mails(folder string) ([]Email, error)
commit a9e372185ed0569226ff1399a3bb30e57d0808b7
Author: x <x@mail.blmayer.dev>
Date: Mon Jun 19 16:15:53 2023 -0300
Adjusted dark theme
* Improved pgp key
diff --git a/www/compose.html b/www/compose.html
index c9ad0c5..09bf97e 100644
--- a/www/compose.html
+++ b/www/compose.html
@@ -28,10 +28,22 @@
<td style="padding-left: 0"><label>Subject: </label></td>
<td><input style="width:100%" name=subject {{if .Query.subj}}value="{{.Query.Get "subj"}}"{{end}}></td>
</tr>
+ <tr>
+ <td colspan=2><textarea style="width:100%" name=body rows="7" cols="50" placeholder="Body:"></textarea></td>
+ </tr>
+ <tr>
+ <td colspan=2><label>Attachments: </label><input type=file name=files multiple></td>
+ </tr>
+ <tr>
+ <td colspan=2>
+ <details>
+ <summary><label>Encrypt? </label><input name=encrypt type=checkbox></summary>
+ Override OpenPGP key (optional):<br>
+ <textarea style="width:100%" name=key rows="7" cols="50" placeholder="Begin OpenGPG key..."></textarea>
+ </details>
+ </td>
+ </tr>
</table>
- <field><textarea style="width:100%" name=body rows="7" cols="50" placeholder="Body:"></textarea><br></field>
- <br>
- <label>Attachments: </label><input type=file name=files multiple><br>
<input type=submit value=send>
</form>
</body>
commit a9e372185ed0569226ff1399a3bb30e57d0808b7
Author: x <x@mail.blmayer.dev>
Date: Mon Jun 19 16:15:53 2023 -0300
Adjusted dark theme
* Improved pgp key
diff --git a/www/head.html b/www/head.html
index 567e3b7..e569140 100644
--- a/www/head.html
+++ b/www/head.html
@@ -1,4 +1,5 @@
<title>dovel</title>
<link rel=icon href=/assets/favicon.ico>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
-{{template "style-min.html"}}
+<meta name="color-scheme" content="light dark"/>
+{{template "style.html"}}
commit a9e372185ed0569226ff1399a3bb30e57d0808b7
Author: x <x@mail.blmayer.dev>
Date: Mon Jun 19 16:15:53 2023 -0300
Adjusted dark theme
* Improved pgp key
diff --git a/www/style.html b/www/style.html
new file mode 100644
index 0000000..4cce72c
--- /dev/null
+++ b/www/style.html
@@ -0,0 +1,34 @@
+<style>
+ body {
+ max-width: 600px;
+ padding: 0 15px;
+ margin: 40px auto;
+ font-family: sans-serif;
+ }
+ table {
+ width: 100%;
+ }
+ a {
+ color: #888
+ }
+ small {
+ float: right;
+ }
+ input, textarea {
+ color: #888;
+ font-family: monospace;
+ }
+ input {
+ border: none;
+ border-bottom: 1px solid #888;
+ }
+ input[type="submit"] {
+ text-decoration: underline;
+ cursor: pointer;
+ color: #888;
+ }
+ pre {
+ white-space: pre-wrap;
+ }
+</style>
+