Overview
Comment: | bump, add option to filter header fields and also add "Date:" by default |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | v0.3.2 |
Files: | files | file ages | folders |
SHA3-256: |
28fde40f7ab330a17ed501c9158a90cd |
User & Date: | arcade on 2024-12-27 15:29:14.977 |
Other Links: | manifest | tags |
Context
2024-12-28
| ||
09:27 | fix markdown, condense From: and Date: to one line (better rework that later) check-in: 3d13e7f81d user: arcade tags: trunk, v0.3.3 | |
2024-12-27
| ||
15:29 | bump, add option to filter header fields and also add "Date:" by default check-in: 28fde40f7a user: arcade tags: trunk, v0.3.2 | |
2024-12-11
| ||
06:25 | one more output error check-in: 562951709a user: arcade tags: trunk, v0.3.1 | |
Changes
Modified Cargo.lock
from [79b2fb9a5a]
to [9b230eb80c].
︙ | |||
24 25 26 27 28 29 30 | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | - + - + - + | checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "anyhow" |
︙ | |||
181 182 183 184 185 186 187 | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | - + - + - + - + | name = "autocfg" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-lc-rs" |
︙ | |||
254 255 256 257 258 259 260 | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | - + | "log", "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", |
︙ | |||
309 310 311 312 313 314 315 | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | - + - + | name = "bytes" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cc" |
︙ | |||
408 409 410 411 412 413 414 | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | - + - + | name = "core-foundation-sys" version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "crossbeam-utils" |
︙ | |||
457 458 459 460 461 462 463 | 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | - + - + | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version", |
︙ | |||
524 525 526 527 528 529 530 | 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | - + | [[package]] name = "errno" version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", |
︙ | |||
665 666 667 668 669 670 671 | 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | - + | name = "futures-macro" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", |
︙ | |||
809 810 811 812 813 814 815 | 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 | - + - + | name = "httpdate" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" |
︙ | |||
973 974 975 976 977 978 979 | 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 | - + | name = "icu_provider_macros" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", |
︙ | |||
1104 1105 1106 1107 1108 1109 1110 | 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 | - + - + - + | name = "lazycell" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" |
︙ | |||
1172 1173 1174 1175 1176 1177 1178 | 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 | - + | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c60f4b1d7bed01be9f6fa08ad92c50f1d53c61e1461a058b94197046bfc5844f" dependencies = [ "bufstream-fresh", "cfg-if", "log", "mailin", |
︙ | |||
1207 1208 1209 1210 1211 1212 1213 | 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 | - + - + | name = "minimal-lexical" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" |
︙ | |||
1263 1264 1265 1266 1267 1268 1269 | 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 | - + - + | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "object" |
︙ | |||
1299 1300 1301 1302 1303 1304 1305 | 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 | - + | name = "openssl-macros" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", |
︙ | |||
1361 1362 1363 1364 1365 1366 1367 | 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 | - + | name = "pin-project-internal" version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", |
︙ | |||
1415 1416 1417 1418 1419 1420 1421 | 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 | - + | [[package]] name = "prettyplease" version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", |
︙ | |||
1453 1454 1455 1456 1457 1458 1459 | 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 | - + - + | checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] [[package]] name = "quote" |
︙ | |||
1591 1592 1593 1594 1595 1596 1597 | 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 | - + - + - + | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", |
︙ | |||
1641 1642 1643 1644 1645 1646 1647 | 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 | - + - + | checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ "rustls-pki-types", ] [[package]] name = "rustls-pki-types" |
︙ | |||
1719 1720 1721 1722 1723 1724 1725 | 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 | - + - + - + - + - + - + - + | "core-foundation-sys", "libc", "security-framework-sys", ] [[package]] name = "security-framework-sys" |
︙ | |||
1840 1841 1842 1843 1844 1845 1846 | 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 | - + | name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smtp2tg" |
︙ | |||
1897 1898 1899 1900 1901 1902 1903 | 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 | - + - + - + | "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "syn" |
︙ | |||
2022 2023 2024 2025 2026 2027 2028 | 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 | - + | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", "once_cell", "rustix", |
︙ | |||
2048 2049 2050 2051 2052 2053 2054 | 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 | - + | name = "thiserror-impl" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", |
︙ | |||
2188 2189 2190 2191 2192 2193 2194 | 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 | - + - + | name = "try-lock" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "unicase" |
︙ | |||
2297 2298 2299 2300 2301 2302 2303 | 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 | - + | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", "proc-macro2", "quote", |
︙ | |||
2332 2333 2334 2335 2336 2337 2338 | 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 | - + | name = "wasm-bindgen-macro-support" version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", |
︙ | |||
2583 2584 2585 2586 2587 2588 2589 | 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 | - + - + | name = "yoke-derive" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", |
︙ | |||
2633 2634 2635 2636 2637 2638 2639 | 2633 2634 2635 2636 2637 2638 2639 2640 2641 | - + | name = "zerovec-derive" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", |
Modified Cargo.toml
from [fe6941924f]
to [de4fd23fd1].
1 2 | 1 2 3 4 5 6 7 8 9 10 | - + | [package] name = "smtp2tg" |
︙ |
Modified smtp2tg.toml.example
from [ef25ee8434]
to [ad2bc6b8b6].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | + + | # Telegram API key api_key = "YOU_KNOW_WHERE_TO_GET_THIS" # where to listen on (sockets are not supported since 0.3.0) listen_on = "0.0.0.0:25" # whether we need to handle unknown adresses # - relay: send them to default one # - deny: drop them unknown = "relay" # default fields to show in message header fields = [ "date", "from", "subject" ] [recipients] # there should be default recipient, get's some debug info + mail that we # couldn't deliver (if enabled) _ = 1 # make sure you quote emails, as "@" can't go there unquoted. And by default # we need FQDNs |
︙ |
Modified src/main.rs
from [a10b8e47fa]
to [64a6b71a91].
︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | + + + + | #[derive(Clone)] struct TelegramTransport { data: Vec<u8>, headers: Option<SomeHeaders>, recipients: HashMap<String, ChatId>, relay: bool, tg: teloxide::adaptors::DefaultParseMode<teloxide::adaptors::Throttle<Bot>>, fields: HashSet<String>, } impl TelegramTransport { /// Initialize API and read configuration fn new(settings: config::Config) -> TelegramTransport { let tg = Bot::new(settings.get_string("api_key") .expect("[smtp2tg.toml] missing \"api_key\" parameter.\n")) .throttle(teloxide::adaptors::throttle::Limits::default()) .parse_mode(MarkdownV2); let recipients: HashMap<String, ChatId> = settings.get_table("recipients") .expect("[smtp2tg.toml] missing table \"recipients\".\n") .into_iter().map(|(a, b)| (a, ChatId (b.into_int() .expect("[smtp2tg.toml] \"recipient\" table values should be integers.\n") ))).collect(); if !recipients.contains_key("_") { eprintln!("[smtp2tg.toml] \"recipient\" table misses \"default_recipient\".\n"); panic!("no default recipient"); } let fields = HashSet::<String>::from_iter(settings.get_array("fields") .expect("[smtp2tg.toml] \"fields\" should be an array") .iter().map(|x| x.clone().into_string().expect("should be strings"))); let value = settings.get_string("unknown"); let relay = match value { Ok(value) => { match value.as_str() { "relay" => true, "deny" => false, _ => { |
︙ | |||
91 92 93 94 95 96 97 98 99 100 101 102 103 104 | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | + | TelegramTransport { data: vec!(), headers: None, recipients, relay, tg, fields, } } /// Send message to default user, used for debug/log/info purposes async fn debug<'b, S>(&self, msg: S) -> Result<Message> where S: Into<String> { Ok(self.tg.send_message(*self.recipients.get("_").unwrap(), msg).await?) |
︙ | |||
136 137 138 139 140 141 142 | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | + - - - - - - + + + + + + + + + + + + + + | self.debug("No recipient or envelope address\\.").await?; rcpt.insert(self.recipients.get("_") .ok_or(anyhow!("Missing default address in recipient table."))?); }; // prepating message header let mut reply: Vec<Cow<'_, str>> = vec![]; if self.fields.contains("subject") { |
︙ | |||
322 323 324 325 326 327 328 | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | - + + | result } } #[async_std::main] async fn main() -> Result<()> { let settings: config::Config = config::Config::builder() |
︙ |