piknik icon indicating copy to clipboard operation
piknik copied to clipboard

Send mail with gmail smtp server, got error Error { kind: Response, source: "incomplete response" }

Open ipconfiger opened this issue 2 years ago • 4 comments

Describe the bug Send mail with gmail smtp server, got error Error { kind: Response, source: "incomplete response" }

To Reproduce Code allowing to reproduce the bug.

    let from = "********@gmail.com".parse().unwrap();
    // 设置收件人邮箱地址
    let to = "*****@xxx.com".parse().unwrap();
    // 创建邮件
    let email = Message::builder()
        .from(from)
        .to(to)
        .subject(title)
        .header(ContentType::TEXT_PLAIN)
        .body(content)
        .unwrap();

    let smtp_server = "smtp.gmail.com";
    let smtp_port = 587;
    let username = "*****@gmail.com";
    let password = "*******";
    
    let smtp_transport = SmtpTransport::starttls_relay(smtp_server)
        .unwrap()
        .credentials(Credentials::new(username.to_string(), password.to_string()))
        .port(smtp_port).build();

    let result = smtp_transport.send(&email);
    match result {
        Ok(_) => println!("Email sent successfully!"),
        Err(e) => panic!("Could not send email: {e:?}"),
    }

Expected behavior send mail success

Environment (please complete the following information):

  • Lettre version "0.10.0"
  • OS MacOS 13.2.1

ipconfiger avatar Apr 01 '23 09:04 ipconfiger

Same issue with yandex smtp :(

n00bsteam avatar Apr 11 '23 08:04 n00bsteam

For Gmail you would need to turn on MFA and then create an app password, it didn't work with a normal password for me. If you have any issues let me know.

c-git avatar Apr 12 '23 22:04 c-git

For Gmail you would need to turn on MFA and then create an app password, it didn't work with a normal password for me. If you have any issues let me know.

For me, all works fine with Gmail and application password, but have a problem with yandex, and yes, I'm using application password.

Come here from this thread - https://vaultwarden.discourse.group/t/smtp-error-response-error-incomplete-response/2466

n00bsteam avatar Apr 13 '23 10:04 n00bsteam

Never used yandex so IDK but I've tried Gmail and can confirm application password works for me as well

c-git avatar Apr 13 '23 15:04 c-git