Closed soywod closed 1 year ago
I think most TUI's would provide their own UI for setting the options expressed in the MML. How would they interface? Maybe builder pattern initialized struct that devs could hook in too?
Going through the above showed me I know little about mail. Because of that following is going to be wrong in many ways but it might be a good start to get thinking going:
use Content::{Jpeg, RichTxt};
let enriched = todo!("a string or possibly some rich text AST?");
let mail: MailMsg = MailComposer::new()
.subject("test")
.add(Jpeg{
filename: "rms.jpg",
bytes: include_bytes!(rms.jpg)
})
.add_plain("This is a plain text part.")
.add(RichTxt{
name: "enriched.txt",
ast: enriched
})
.add_plain("This is a new plain text part.")
.attach("This plain text part is an attachment.")
.compose(); // Note no unwrap types should allow only correct usage
This calls to mind a few questions:
Content-Disposition
and Content-Transfer-Encoding
field?The message builder already exists in the lettre
1 crate. Himalaya
uses it to convert a message into a "sendable" one 2 (because the
lettre
crate also contains a SMTP client, so we can use it to build
AND send messages). The question is how to interface a "message
language" alla Emacs's MML with the lettre
message builder?
The first step would be to develop a DSL (maybe using the nom
crate
3). We just need some basic features from MML, like <!#part />
and
<!#multipart />
The second step would be to map the parsed AST into a sendable message
using the lettre
message builder.
On 24 Mar 2022, at 22:14 (+0100), soywod/himalaya wrote:
I think most TUI's would provide their own UI for setting the options expressed in the MML. How would they interface? Maybe builder pattern initialized struct that devs could hook in too?
Going through the above showed me I know little about mail. Because of that following is going to be wrong in many ways but it might be a good start to get thinking going:
use Content::{Jpeg, RichTxt}; let enriched = todo!("a string or possibly some rich text AST?"); let mail: MailMsg = MailComposer::new() .subject("test") .add(Jpeg{ filename: "rms.jpg", bytes: include_bytes!(rms.jpg) }) .add_plain("This is a plain text part.") .add(RichTxt{ name: "enriched.txt", ast: enriched }) .add_plain("This is a new plain text part.") .attach("This plain text part is an attachment.") .compose(); // Note no unwrap types should allow only correct usage
This calls to mind a few questions:
- Should each variant of the Content enum have a
Content-Disposition
andContent-Transfer-Encoding
field?- Does each content type need a name?
-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/341#issuecomment-1078337878 You are receiving this because you were assigned.
Message ID: @.***>
-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me
Added by #431 :tada:
Context
Frontends are not all equal in features when it comes to message composition. Emacs has some built-in features that makes the composition experience really great (contact completion, MML language for attachments, coloured syntax etc), whereas the Vim plugin is quite limited (only the coloured syntax), and TUI/GUI may be even worse.
Problem
For now, frontends use the
save
andsend
commands which requires raw MIME message. It means that frontends have the responsibility to produce valid MIME messages. The responsibility should be moved to the lib.Solution
I propose to implement sth similar to what the MML language does in Emacs. This language allows us to write messages in a pseudo code (kind of a template). Then this template is "compiled" into a fully valid MIME message. For example, the following pseudo-message:
will be compiled into: