stalwartlabs / mail-builder

E-mail builder library for Rust
https://docs.rs/mail-builder/
Apache License 2.0
54 stars 17 forks source link

Support for multipart/signed & multipart/encrypted #22

Closed saschabacardit closed 9 months ago

saschabacardit commented 9 months ago

I am working on a PGP compliant email application using this library and I've noticed however that adding a content_type to the headers of a message_builder such that

message_builder.header("Content-Type", "multipart/encrypted; protocol=\"application/pgp-encrypted\"") (See https://datatracker.ietf.org/doc/html/rfc3156#section-4) Doesn't do anything, that is because when the message_builder gets transformed into a string via write the function fn write_to(self, mut output: impl Write) -> io::Result<()> which after adding date and message-id fields, will proceed to. call fn write_body(self, output: impl Write) -> io::Result<()> which, before writing does set the Content-Type depending on the contents, which becomes an issue as for PGP messages it is required to have the correct multipart (see https://datatracker.ietf.org/doc/html/rfc3156#section-4 & https://datatracker.ietf.org/doc/html/rfc1847#section-2).

I however, see that Stalwartlabs has a PGP compliant email application (see https://stalw.art/) so maybe I am misusing the library and this is a non-issue. If not, and mail-builder indeed does not handle custom content-types, could it be possible to make a PR for it with a possible solution or the project isn't open to them?

Apologies if this isn't the proper way to ask this sort of questions/issues, it is my first time working with open source projects.

mdecimus commented 9 months ago

Hi,

Please check the nested email example to see how you could create a custom part:

https://github.com/stalwartlabs/mail-builder/blob/main/examples/nested_message.rs

saschabacardit commented 9 months ago

Thank you, it seems I was using the library incorrectly.

I'll close the issue as I assume (correctly, or not) that the handling of these content types is beyond the intended scope of mail-builder.