vaultwarden/src/aws.rs
Chase Douglas ed5ee5f25e mail: add AWS SES transport
Serverless AWS deployments should not need an SMTP service or SMTP
credentials just to send Vaultwarden mail. Allow mail delivery through
Amazon SES when USE_AWS_SES is enabled, while preserving the existing SMTP
and sendmail transports.

Add the ses feature and an aws umbrella feature. Keep mail config
validation strict by requiring SMTP_FROM for SES, and treat SES as a
configured mail transport for email 2FA.

Send MIME messages through the SESv2 SendEmail raw content path. Share AWS
SDK configuration with S3 so AWS clients use the same reqwest-backed
connector and credential loading behavior.
2026-05-05 15:49:04 -07:00

27 lines
829 B
Rust

use aws_config::{AppName, BehaviorVersion};
use tokio::sync::OnceCell;
use crate::http_client::aws::AwsReqwestConnector;
fn aws_reqwest_connector() -> AwsReqwestConnector {
let reqwest_client = reqwest::Client::builder().build().expect("Failed to build reqwest client");
AwsReqwestConnector {
client: reqwest_client,
}
}
pub(crate) async fn aws_sdk_config() -> &'static aws_config::SdkConfig {
static AWS_CONFIG: OnceCell<aws_config::SdkConfig> = OnceCell::const_new();
AWS_CONFIG
.get_or_init(|| async {
aws_config::defaults(BehaviorVersion::latest())
.app_name(AppName::new("vaultwarden").expect("Failed to build AWS app name"))
.http_client(aws_reqwest_connector())
.load()
.await
})
.await
}