~witcher/public-inbox

Drop some unnecessary lettre features v1 APPLIED

Hugo Osvaldo Barrera: 3
 Drop some unnecessary lettre features
 Leave a note on the impact of the "pool" feature
 Trace-log sending of individual messages

 4 files changed, 6 insertions(+), 3 deletions(-)
My bad, I picked the wrong one from my shell history.

I just realised I can configure this just one per checked-out repo:

    git config sendemail.to "~witcher/rss-email-devel@lists.sr.ht"
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~witcher/public-inbox/patches/37491/mbox | git am -3
Learn more about email & git

[PATCH 1/3] Drop some unnecessary lettre features Export this patch

---
 Cargo.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Cargo.toml b/Cargo.toml
index 67e6d70..a565e00 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,7 @@ reqwest = {version = "0.11", default-features = false, features = ["rustls-tls"]
clap = { version = "3", features = ["derive"] }
chrono = "0.4"
toml = "0.5.8"
lettre = { version = "0.10.1", default-features = false, features = ["rustls", "rustls-tls", "builder", "smtp-transport", "pool", "tokio1", "tokio1-rustls-tls"] }
lettre = { version = "0.10.1", default-features = false, features = ["builder", "smtp-transport", "pool", "tokio1", "tokio1-rustls-tls"] }
serde = { version = "1.0", features = ["derive"] }
directories = "4.0.1"
log = "0.4.17"
-- 
2.38.1
Applied, thank you!
Just a small reminder, I set up a list for patches for rss-email at
https://lists.sr.ht/~witcher/rss-email-devel.

[PATCH 2/3] Leave a note on the impact of the "pool" feature Export this patch

I had previously implemented sending of emails with the async transport
(together with async fetching of RSS), though I now realise I'd never
sent the patch.

While implementing this, I realised that the "pool" feature has a huge
impact on the speed of sending emails: by merely having the feature
enabled the transport instance will keep the connection open between
messages (avoiding a connecting and authenticating a second time).

Just leaving a comment on that for future reference.
---
 Cargo.toml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Cargo.toml b/Cargo.toml
index a565e00..0f205ec 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,6 +14,8 @@ reqwest = {version = "0.11", default-features = false, features = ["rustls-tls"]
clap = { version = "3", features = ["derive"] }
chrono = "0.4"
toml = "0.5.8"
# Adding the "pool" feature changes the behaviour so that a transport keeps a
# connection open between sent emails.
lettre = { version = "0.10.1", default-features = false, features = ["builder", "smtp-transport", "pool", "tokio1", "tokio1-rustls-tls"] }
serde = { version = "1.0", features = ["derive"] }
directories = "4.0.1"
-- 
2.38.1

[PATCH 3/3] Trace-log sending of individual messages Export this patch

---
This mostly helped me figure out that the `pool` feature did what I expected,
and is mostly useful for debugging this kind of thing.
 src/mail.rs | 3 ++-
 src/main.rs | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mail.rs b/src/mail.rs
index d895b9f..382609a 100644
--- a/src/mail.rs
+++ b/src/mail.rs
@@ -23,7 +23,7 @@ pub async fn send_email<S, I>(
    config: &Config,
    subject: S,
    body: I,
    mailer: AsyncSmtpTransport<Tokio1Executor>,
    mailer: &AsyncSmtpTransport<Tokio1Executor>,
) -> anyhow::Result<()>
where
    S: AsRef<str>,
@@ -35,6 +35,7 @@ where
        .subject(subject.as_ref())
        .body(body.into())?;

    trace!("Sending to {}: {}", config.to, subject.as_ref());
    mailer.send(email).await?;

    Ok(())
diff --git a/src/main.rs b/src/main.rs
index 9d30382..08122d0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -115,7 +115,7 @@ where
            Some(c) => c + "\n\n" + &post.url.unwrap(),
            None => post.url.unwrap(),
        };
        send_email(&config, subject, body, mailer).await?;
        send_email(&config, subject, body, &mailer).await?;
    }

    sqlx::query!("update posts set sent = true where guid = ?", post.guid)
-- 
2.38.1