Check-in [51adce1e7e]
Logged in as anonymous
Overview
Comment:use LMTP for socket server
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 51adce1e7e85ed9a5c33a50e44d6a8cd93b850f98718f0eb3f2b7de3b40e2e40
User & Date: arcade on 2024-05-22 13:31:58.009
Other Links: manifest | tags
Context
2024-05-22
13:39
mess with header/body formatting check-in: 667b874fdb user: arcade tags: trunk
13:31
use LMTP for socket server check-in: 51adce1e7e user: arcade tags: trunk
13:00
well, it kindda works... check-in: 61238a3618 user: arcade tags: trunk
Changes
1
2
3
4
5
6
7
8
9
10




11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
17
18
19
20









-
+
+
+
+







use anyhow::Result;
use async_std::task;
use samotop::{
	mail::{
		Builder,
		DebugService,
		MailDir,
		Name
	},
	smtp::Prudence,
	smtp::{
		SmtpParser,
		Prudence,
	},
};
use telegram_bot::{
	Api,
	ParseMode,
	SendMessage,
	UserId,
};
222
223
224
225
226
227
228
229
230
231

232
233
234
235
236
237
238
239
240


241
242
243
244








245
246
225
226
227
228
229
230
231



232
233
234
235
236
237
238
239
240
241
242
243




244
245
246
247
248
249
250
251
252
253







-
-
-
+









+
+
-
-
-
-
+
+
+
+
+
+
+
+


		.add_source(config::File::with_name("smtp2tg.toml"))
		.build().unwrap();

	let core = TelegramTransport::new(&settings);
	let maildir: PathBuf = settings.get_string("maildir").unwrap().into();
	let listen_on = settings.get_string("listen_on").unwrap();
	let sink = Builder + Name::new("smtp2tg") + DebugService +
		samotop::smtp::Esmtp.with(samotop::smtp::SmtpParser) + my_prudence() +
		//TelegramTransport::new(&settings);
		MailDir::new(maildir.clone()).unwrap();
		my_prudence() + MailDir::new(maildir.clone()).unwrap();

	task::spawn(async move {
		loop {
			relay_mails(&maildir, &core).unwrap();
			task::sleep(Duration::from_secs(5)).await;
		}
	});

	match listen_on.as_str() {
		"socket" => {
			let sink = sink + samotop::smtp::Lmtp.with(SmtpParser);
		"socket" => samotop::server::UnixServer::on("./smtp2tg.sock")
			.serve(sink.build()).await.unwrap(),
		_ => samotop::server::TcpServer::on(listen_on)
			.serve(sink.build()).await.unwrap(),
			samotop::server::UnixServer::on("./smtp2tg.sock")
				.serve(sink.build()).await.unwrap();
		},
		_ => {
			let sink = sink + samotop::smtp::Esmtp.with(SmtpParser);
			samotop::server::TcpServer::on(listen_on)
				.serve(sink.build()).await.unwrap();
		},
	};
}