Comments (10)
I've run into a problem that sounds similar to this one.
Here is some code which might help you reproduce it. I have replaced all the addresses, servers and credentials that I used in my test, with todo!()
s.
The value of snip
is crucial: with its current value (or greater) the message send hangs. For any smaller value of snip
the message gets sent successfully without delay. Changing the length of the addresses used, changes the value of snip
that crosses the threshold between success and failure, so it looks like it depends on total message size.
Every PDF I tried (whose size exceeds snip
) caused this failure. Including ones I have managed to send successfully using the server I used in my tests (with manual MUAs).
use mail_send::{mail_builder::MessageBuilder, Transport};
#[tokio::main]
async fn main() {
let snip = 55663;
let sender_name = todo!();
let sender_address = todo!();
let smtp_server = todo!();
let username = todo!();
let pw = todo!();
let recipient_name = todo!();
let recipient_address = todo!();
let pdf_attachment = include_bytes!("../../sample.pdf").as_ref();
let pdf_attachment = &pdf_attachment[..snip];
let message = format!("PDF attachment length: {}", pdf_attachment.len());
println!("{message}");
let message = MessageBuilder::new()
.from((sender_name, sender_address))
.to(vec![
(recipient_name, recipient_address),
])
.subject(&message)
.text_body(&message)
.binary_attachment("application/pdf", "attachment.pdf", pdf_attachment);
Transport::new(smtp_server)
.credentials(username, pw)
.allow_invalid_certs(true)
.connect_tls()
.await
.unwrap()
.send(message)
.await
.unwrap();
}
from mail-send.
Hi @jacg ,
I was able to reproduce the problem with your code snippet. The buffer was not being properly flushed, that is why it was getting stuck.
I just pushed a fix for this bug to the main branch, can you confirm that it works for you as well?
Thanks.
from mail-send.
It may be related to the same problem. I'm looking into this now and will send you an update soon.
from mail-send.
It seems to work correctly for me now.
Many thanks for the quick solution!
from mail-send.
Great! Version 0.2.3 has been pushed to crates.io with the fix.
from mail-send.
In order to reproduce the problem, could you provide the code you're using and if possible also the binary attachment?
from mail-send.
Closing as no reply was received in 14 days.
from mail-send.
I can confirm that it no longer blocks. But (after removing all the snip
ping) the PDF document arrives 'damaged' at the other end, and I cannot open it with any of the PDF viewers I tried.
from mail-send.
The document I'm using to test is 95k, but the one that is received is 130k. I'll try to come up with some more precise information when I have more time. Would you like me to file a separate issue for this, or continue here?
from mail-send.
Done, it should work now.
from mail-send.
Related Issues (11)
- ✨ Feature request: OpenPGP encryption support HOT 18
- thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: MissingStartTls HOT 7
- Add an `impl std::error::Error` for `mail_send::Error` HOT 4
- `UnparseableReply`: Bug in `impl<T: AsyncRead + AsyncWrite + Unpin> SmtpClient<T>`. (Fixed by #13) HOT 5
- Sample Usage using XOAuth2 for SMTP Sending of Email HOT 2
- Disable SSL/TLS HOT 1
- Non-async support? HOT 4
- Integration with mail-parser HOT 3
- some error with error display (i don't know how to describe accurate) HOT 2
- Fails to compile (Even in hello world) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mail-send.