skerkour / kerkour.com

(Ab)using technology for fun & profit. Programming, Hacking & Entrepreneurship @ https://kerkour.com
https://kerkour.com
Apache License 2.0
463 stars 63 forks source link

Unable to resolve multiple types in email sending example #12

Closed vbmade2000 closed 2 years ago

vbmade2000 commented 2 years ago

Tried to compile an example that shows email sending. Got this error.

error[E0433]: failed to resolve: could not find `smtp` in `transport`
 --> src/main.rs:2:17
  |
2 |      transport::smtp::authentication::Credentials, AsyncSmtpTransport, AsyncTransport, Message,
  |                 ^^^^ could not find `smtp` in `transport`

error[E0432]: unresolved imports `lettre::AsyncSmtpTransport`, `lettre::AsyncTransport`, `lettre::Tokio1Executor`
 --> src/main.rs:2:52
  |
2 |      transport::smtp::authentication::Credentials, AsyncSmtpTransport, AsyncTransport, Message,
  |                                                    ^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^ no `AsyncTransport` in the root
  |                                                    |
  |                                                    no `AsyncSmtpTransport` in the root
3 |      Tokio1Executor,
  |      ^^^^^^^^^^^^^^ no `Tokio1Executor` in the root

error[E0433]: failed to resolve: use of undeclared type `Credentials`
 --> src/main.rs:9:10
  |
9 |          Credentials::new("smtp_username".to_string(), "smtp_password".to_string());
  |          ^^^^^^^^^^^ use of undeclared type `Credentials`
vbmade2000 commented 2 years ago

Looks like you have to enable tokio1 and smtp-transport features of lettre crate.

sylvain101010 commented 2 years ago

Yes, You can see here the features to enable :) https://github.com/skerkour/kerkour.com/blob/076b1612765016c48a2c12632dca5ebdcb59681e/2021/2021_03_16_how_to_send_emails_in_rust/Cargo.toml#L13