Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Arif Driessen
@arifd
Any idea how to solve this? Thanks in advance!
kevincox
@kevincox:matrix.org
[m]

:point_up: Edit: FWIW I did manage to get lettre to send by manually looking up MX records and generating a transport. It was fairly awkward because a lot of the building blocks require lots of allocation and try to have individual connection pools but it did work. I should try to summarize what I did on the bug.

One day I hope to implement this "properly" and see if I can implement the transport interface.

Arif Driessen
@arifd
Hi guys, looking at how you do your integration tests... Looks like you just use builder_dangerous("127.0.0.1").port(2525). Does that imply that before you run your tests you start an email server on your local machine? Would be great if there was a rust crate i could use for this, so i could include it as a dev-dependency
1 reply
kevincox
@kevincox:matrix.org
[m]
Hi, I'm hoping to get lettre/lettre#670 landed and wanted to check in on the next steps. The PR definitely needs a bit of polish but before I put time into that I wanted to make sure that it will be accepted. I've been using the implementation for a month or so now to send signed mail so it definitely works at least in some configurations (some known bugs will be addressed, probably in followups) so I was hoping to get it merged in so that I can get back to upstream lettre and continue building on top of it.
paolobarbolini
@paolobarbolini:matrix.org
[m]
Sorry for the delay. We're definitely interested in merging it, although using it before all encoding issues are solved might not be a good idea. I'll try leaving a comment in the following days
kevincox
@kevincox:matrix.org
[m]

Ok. I think all of the encoding issues are resolved now. I am only aware of two outstanding issues.

  1. Simple header signing doesn't work because the DKIM signature header is wrapped differently after the signature value is inserted. This should be easy to fix by inserting a fake signature during formatting then truncating it to get the correct wrapping.
  2. I saw issues with multi-part bodies before. However I haven't tried that again so don't know if this still exists.

For both my preferred option would be to get the current code merged and then I will fix the bugs as follow ups. The PR is fairly large so I think this makes the most sense.

Cleanup I will do once we think the main code is correct:

  1. Add more full-message tests with hardcoded timestamps.
  2. Docstrings.
  3. Add an experimental warning for now.
Actually I think there is also a bug when the list of signed headers nears 78 chars due to bugs in lettre's header wrapping. But this isn't really a bug with the DKIM implementation. This could maybe be worked around by formatting the signed header list as h=To: From: Subject: instead of h=To:From:Subject.
1 reply
Good to see that resolved. Currently I am running on kevincox/lettre@ebc69f0 which solves the issue at least until 995 characters which is good enough for my use case. But good to see the proper solution landing.
paolobarbolini
@paolobarbolini:matrix.org
[m]
Yeah this time we're going to implement it the proper way. lettre 0.9 used the email crate, which is very old an unmaintained at this point, 0.10 initially used hyperx which is really meant for HTTP. In removing it I was hoping we could do away with a generic implementation but the last months of issues have demonstrated that we can't
kevincox
@kevincox:matrix.org
[m]
Yeah. Although there is really no perfect solution. SMTP is not the best protocol. For example if you want to include a List-Unsubscribe header of more than 995 characters you are out of luck, there is no legal way to encode that AFAIK. That being said most headers have enough breaking points that this isn't an issue.
paolobarbolini
@paolobarbolini:matrix.org
[m]
In a world where different providers start getting things together we may be able to get to play with JMAP πŸ˜ƒ
kevincox
@kevincox:matrix.org
[m]
Does JAMP have goals of replacing the sending half as well? That would be nice.
1 reply
Darn. Plus replacing the reading half is much easier because you only need to support your users. To replace the MTA half you need to support every other MTA in the world. (...or more likely support SMTP fallback forever)
soulflyman
@soulflyman:matrix.org
[m]

Hi everyone, has someone managed to send a mail with lettre via smtp.office365.com? I can't get it working and get an timeout after 30 seconds.

ERROR: Could not send email: Err(Io(Os { code: 10060, kind: TimedOut, message: "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond." }))

1 reply
kevincox
@kevincox:matrix.org
[m]
What port are you using? If it is port 25 it is commonly blocked.
soulflyman
@soulflyman:matrix.org
[m]
port is 587
where can i find SmtpTransport::starttls_relay? I can't find it in the doc
1 reply
paolobarbolini
@paolobarbolini:matrix.org
[m]
Does telnet smtp.office365.com 587 work?
soulflyman
@soulflyman:matrix.org
[m]
telnet smtp.office365.com 587
Trying 52.97.149.82...
Connected to smtp.office365.com.
Escape character is '^]'.
220 AM6PR02CA0026.outlook.office365.com Microsoft ESMTP MAIL Service ready at Tue, 8 Feb 2022 17:14:43 +0000
looks good to me
paolobarbolini
@paolobarbolini:matrix.org
[m]
I don't have a better example if you're on lettre 0.9, but you can copy from here https://docs.rs/lettre/0.9.6/src/lettre/smtp/mod.rs.html#137-143
and change SUBMISSIONS_PORT to 587 and ClientSecurity::Wrapper to ClientSecurity::Required
1 reply
Unfortunately I don't think 0.9 had a better API for connecting using STARTTLS, which is what seems to work with smtp.office365.com
bilemon
@bilemon

Halloo. I'm attempting to upgrade some services to use lettre. At the moment, when I try and test_connection, I'm receiving an ssl error, and I'm not sure what the appropriate configuration/setup for lettre is at the moment.

I am using lettre = "0.10.0-rc.4"

I can verify that the mail service is accepting mail over the submissions port 587

openssl s_client -debug -starttls smtp -connect my.mail.server:587
EHLO account@mail.server
AUTH LOGIN
account
passphrase


<success response>

I am able to send mail over tls through telnet as well as through other libraries.

When I try and use lettre, I am doing the following:

let email = Message::builder().from(...).to(...).body(...).unwrap()
let creds = Credentials::new("mail_user".to_string(), "mail_user_pass".to_string())
let smtp = SmtpTransport::starttls_relay("my.mail.server").unwrap().credentials(creds).build()

match smtp.test_connection() {
    Ok(_) => println!("success!"),
    Err(e) => println("{:?}", e),
}

Unfortunately, I receive:

lettre::transport::smtp::Error { kind: Connection, source: Failure(Ssl(Error { code: ErrorCode(1), cause: Some(Ssl(ErrorStack([Error { code: 337047686, library: "SSL routines", function: "tls_process_server_certificate", reason: "certificate verify failed", file: "ssl/statem/statem_clnt.c", line: 1914 }]))) }, X509VerifyResult { code: 18, error: "self signed certificate" })) }

Hopefully I'm just doing something foolish, but before I dig into the lettre code, I was hoping someone here might have a pointer. I'd very much like to use lettre rather than roll my own, so any tips would be appreciated.
Thanks!

5 replies
kevincox
@kevincox:matrix.org
[m]
I believe that you should also be able to configure a pinned certificate check if you wanted to have strong security.
bilemon
@bilemon
Thanks @kevincox:matrix.org . This is just a quick test, so I'm fine without the check. Appreciate it though.
bilemon
@bilemon

@paolobarbolini:matrix.org Apologies for this next question, but it seems that lettre's implementation of Headers requires each header to be typed. My use case requires that a client will pass me a series of custom headers which I must inspect before sending some mail. In this case, it seems that lettre has chosen to declare each header, and I'm not sure how to work with arbitrary header keys at runtime.

At the moment, the only way to process headers appears to be via hyperx using header! { (Some-Header, "Some-Header) }, but this doesn't solve the runtime problem.

Am I blocked from using lettre by this without significantly modifying the lettre API?

2 replies
bilemon
@bilemon
something like .add_header(("Foo", "Bar"))from the 0.6.x API
kevincox
@kevincox:matrix.org
[m]
Yeah, I don't think dynamic header names are currently supported by the API. Hopefully soon.
bilemon
@bilemon
@kevincox:matrix.org happy to help contribute and expedite this feature if it’s something the team would like. Lmk
kevincox
@kevincox:matrix.org
[m]

An update on DKIM stuff.

lettre/lettre#688 is the last issue for valid DKIM sending (and this issue affects non-DKIM use cases as well). This is now the only patch I am adding to my instance of lettre running in production sending direct mail to people. (kevincox/lettre@707af8c)

I've only really been testing c=relaxed/simple signing but I think any form of signing should be working with the patch. Maybe I'll try simple/simple in a bit, but I do have one proxy that re-wraps some headers so that may not be possible.

Paolo Barbolini
@paolobarbolini:matrix.org
[m]
Thanks for the update kevincox. I should have some time back in the following weeks so that I can get to this last encoding issue, and then release. Lettre 0.10 has been in the making for a very long time now πŸ˜…
kevincox
@kevincox:matrix.org
[m]

Slow and steady is good πŸ™‚

I think it is definitely good that we are really handling this properly soon. It's kinda a shame that email is such a bad protocol. The fact that you need custom code to encode each header properly is pretty awkward. That being said the kludge that I am using does seem to work well enough. At least until I try to send a header that has a word >997 characters.

kevincox
@kevincox:matrix.org
[m]
πŸŽ‰ lettre/lettre#688 is fixed. I'm excited for the next RC so that I can be on an official (pre) release. Also pretty exciting to me that lettre has fully working DKIM signing. I understand that lettre is mainly aimed at using relays but even then DKIM signing can be useful. For example I use relays for "difficult" inbox providers but I can still use Amazon SES and sign client-side. This was Amazon can't impersonate me even though they are lending me their IPs. (Ok, technically they still can because I added them to SPF but at least I would get reports if they tried).
Thanks Paolo for all your work and gaetronik for the foundations of the DKIM code.
Paolo Barbolini
@paolobarbolini:matrix.org
[m]
Lettre 0.10.0-rc.7 is out. Thanks Kevin for testing it!
Paolo Barbolini
@paolobarbolini:matrix.org
[m]
lettre 0.10.0 is out! https://lettre.rs/post/lettre-0-10/
Mathijs van Veluw
@BlackDex
Nice, πŸŽ‰
Charalampos Mitrodimas
@charmitro
Hello! Anyone knows how to send attachments?
1 reply