async-email / async-smtp

Apache License 2.0
60 stars 13 forks source link

gmail example gives credentials error method not found in `impl std::future::Future` #47

Open Lejla94 opened 3 years ago

Lejla94 commented 3 years ago

I am using the example on github here for gmail. I get the error:


credentials(creds)
^^^^^^^^^^^ method not found in `impl std::future::Future`

I am new to rust sorry. I tried #[async_std::main] but it says i should use it only on main. What could i do?

Lejla94 commented 3 years ago

my cargo toml

async-smtp = "0.4.0"
async-std = {version = "1.10.0", features = ["attributes"]}
Moxinilian commented 3 years ago

The examples are not up to date with the latest version of async_smtp it looks like. As the error suggests, the SmtpClient new method now returns a future for a Result. So you should first await on that result, then unwrap the Result (in whatever way you'd like, for example using ? or matching on the error) to obtain the client instance.

Lejla94 commented 3 years ago

Now i am using tokio with lettre. But after i am good at Rust i will try this again to see what can i do.