Giter VIP home page Giter VIP logo

Comments (10)

jacg avatar jacg commented on May 24, 2024 1

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.

mdecimus avatar mdecimus commented on May 24, 2024 1

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.

mdecimus avatar mdecimus commented on May 24, 2024 1

It may be related to the same problem. I'm looking into this now and will send you an update soon.

from mail-send.

jacg avatar jacg commented on May 24, 2024 1

It seems to work correctly for me now.

Many thanks for the quick solution!

from mail-send.

mdecimus avatar mdecimus commented on May 24, 2024 1

Great! Version 0.2.3 has been pushed to crates.io with the fix.

from mail-send.

mdecimus avatar mdecimus commented on May 24, 2024

In order to reproduce the problem, could you provide the code you're using and if possible also the binary attachment?

from mail-send.

mdecimus avatar mdecimus commented on May 24, 2024

Closing as no reply was received in 14 days.

from mail-send.

jacg avatar jacg commented on May 24, 2024

I can confirm that it no longer blocks. But (after removing all the snipping) 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.

jacg avatar jacg commented on May 24, 2024

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.

mdecimus avatar mdecimus commented on May 24, 2024

Done, it should work now.

from mail-send.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.