-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
AsyncTransport send() indefinitely waits for network up #917
Comments
I'm not sure if a problem I am currently facing is linked to a similar bug, tho I've not observed any connectivity issues. async fn prepare_email(event: &DebouncedEvent) {
let smtp_credentials =
Credentials::new("smtp_creds".to_string(), "smtp_passwd".to_string());
let mailer: AsyncSmtpTransport<Tokio1Executor> = AsyncSmtpTransport::<Tokio1Executor>::relay("smtp.server.address").unwrap()
.credentials(smtp_credentials)
.build();
let from = "from";
let to = "to";
let subject ="subject";
let body = "body";
send_email_smtp(&mailer, from, to, &subject, body).await.unwrap()
}
async fn send_email_smtp(
mailer: &AsyncSmtpTransport<Tokio1Executor>,
from: &str,
to: &str,
subject: &str,
body: String,
) -> Result<(), Box<dyn std::error::Error>> {
let email = Message::builder()
.from(from.parse()?)
.to(to.parse()?)
.subject(subject)
.header(ContentType::TEXT_PLAIN)
.body(body.to_string())?;
let x = mailer.send(email).await;
match x{
Ok(res) => {println!("OK: {:?}",res.code().detail)}
Err(res) => {println!("Error: {:?}",res.status().unwrap().detail)}
}
Ok(())
} Using these two methods, without fail, no matter the send rate, on the 4th call, the line I'm running it on Windows 11 |
Describe the bug
When using either the send() method of the async transport or test_connection, upon the lack of a network connection, they will indefinitely wait for the network to go up before performing work
To Reproduce
Code pseudo-excerpt (config simply contains smtp settings)
To solve this, you can easily wrap any email code around a tokio timeout to be extra safe, but I would have expected this to be implicit behavior of the library itself
I propose adding a config flag for this, but i'm no expert
Expected behavior
I would expect for them to raise some form of Timeout error
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: