-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send gets stuck when the message has a binary attachment #7
Comments
In order to reproduce the problem, could you provide the code you're using and if possible also the binary attachment? |
Closing as no reply was received in 14 days. |
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 The value of Every PDF I tried (whose size exceeds 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();
} |
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. Thanks. |
I can confirm that it no longer blocks. But (after removing all the |
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? |
It may be related to the same problem. I'm looking into this now and will send you an update soon. |
Done, it should work now. |
It seems to work correctly for me now. Many thanks for the quick solution! |
Great! Version 0.2.3 has been pushed to crates.io with the fix. |
Adding a binary attachment makes the sent command get stuck and never finish until the server ends the connection. Sending a text attachment works fine. The binary attachment is only 98Kb.
The text was updated successfully, but these errors were encountered: