Crates.io | relay-mailer |
lib.rs | relay-mailer |
version | 0.1.1 |
source | src |
created_at | 2024-10-06 14:35:06.091063 |
updated_at | 2024-10-06 15:59:59.407977 |
description | An Actix Web server leveraging the lettre crate to relay form field data to email addresses |
homepage | |
repository | https://github.com/harr1424/relay-mailer |
max_upload_size | |
id | 1399126 |
size | 77,783 |
An Actix Web server leveraging the lettre crate to receive, validate, and sanitize form field data and relay it to an email server.
It is necessary to provide a Config.toml
file containing the following:
user = "bob@mail.com"
pwd = "04 08 0F 10 17 2A"
forward_address = "alice@mail.com"
server = "smtp.mail.com"
listen_address = "0.0.0.0:8080"
#[actix_web::main]
pub async fn main() -> std::io::Result<()> {
env_logger::builder().filter_level(LevelFilter::Info).init();
let config = Config::load_from_file("Config.toml").expect("Failed to load configuration file Config.toml");
let config_arc = Arc::new(config.clone());
let limiter = LimiterBuilder::new()
.with_duration(Duration::days(1))
.with_num_requests(4)
.build();
HttpServer::new(move || {
App::new()
.app_data(Data::new(config_arc.clone()))
.wrap(Logger::default())
.wrap(RateLimiter::new(Arc::clone(&limiter)))
.wrap(DefaultHeaders::new().add(("X-Content-Type-Options", "nosniff")))
.wrap(DefaultHeaders::new().add(("X-Robots-Tag", "noindex, nofollow")))
.service(relay_message)
})
.bind(&config.listen_address)?
.run()
.await
}