1
1
extern crate imap;
2
2
extern crate rustls_connector;
3
3
4
- use std:: {
5
- env,
6
- error:: Error ,
7
- net:: TcpStream ,
8
- } ;
4
+ use std:: { env, error:: Error , net:: TcpStream } ;
9
5
10
6
use dotenv:: dotenv;
11
7
use rustls_connector:: RustlsConnector ;
12
8
13
-
14
9
fn main ( ) -> Result < ( ) , Box < dyn Error > > {
15
10
// Read config from environment or .env file
16
11
dotenv ( ) . ok ( ) ;
@@ -26,7 +21,12 @@ fn main() -> Result<(), Box<dyn Error>> {
26
21
Ok ( ( ) )
27
22
}
28
23
29
- fn fetch_inbox_top ( host : String , user : String , password : String , port : u16 ) -> Result < Option < String > , Box < dyn Error > > {
24
+ fn fetch_inbox_top (
25
+ host : String ,
26
+ user : String ,
27
+ password : String ,
28
+ port : u16 ,
29
+ ) -> Result < Option < String > , Box < dyn Error > > {
30
30
// Setup Rustls TcpStream
31
31
let stream = TcpStream :: connect ( ( host. as_ref ( ) , port) ) ?;
32
32
let tls = RustlsConnector :: default ( ) ;
@@ -38,9 +38,7 @@ fn fetch_inbox_top(host: String, user: String, password: String, port: u16) -> R
38
38
39
39
// the client we have here is unauthenticated.
40
40
// to do anything useful with the e-mails, we need to log in
41
- let mut imap_session = client
42
- . login ( & user, & password)
43
- . map_err ( |e| e. 0 ) ?;
41
+ let mut imap_session = client. login ( & user, & password) . map_err ( |e| e. 0 ) ?;
44
42
45
43
// we want to fetch the first email in the INBOX mailbox
46
44
imap_session. select ( "INBOX" ) ?;
0 commit comments