10 个版本
使用旧的 Rust 2015
0.9.4 | 2020年4月21日 |
---|---|
0.9.2 | 2019年6月11日 |
0.9.0 | 2019年3月17日 |
0.8.3 | 2018年11月2日 |
0.7.0 | 2017年10月8日 |
#157 in 电子邮件
11,093 每月下载量
用于 少于 13 crates
510KB
11K SLoC
lettre
Lettre 是一个 Rust 邮件库。
有用链接
特性
Lettre 提供以下特性
- 多种传输方法
- Unicode 支持(用于电子邮件内容和地址)
- 使用加密和身份验证通过 SMTP 安全交付
- 易于使用的电子邮件构建器
示例
此库需要 Rust 1.32 或更高版本。要使用此库,请将以下内容添加到您的 Cargo.toml
[dependencies]
lettre = "0.9"
lettre_email = "0.9"
extern crate lettre;
extern crate lettre_email;
use lettre::{EmailTransport, SmtpTransport};
use lettre_email::EmailBuilder;
use std::path::Path;
fn main() {
let email = EmailBuilder::new()
// Addresses can be specified by the tuple (email, alias)
.to(("[email protected]", "Firstname Lastname"))
// ... or by an address only
.from("[email protected]")
.subject("Hi, Hello world")
.text("Hello world.")
.build()
.unwrap();
// Open a local connection on port 25
let mut mailer = SmtpTransport::builder_unencrypted_localhost().unwrap()
.build();
// Send the email
let result = mailer.send(&email);
if result.is_ok() {
println!("Email sent");
} else {
println!("Could not send email: {:?}", result);
}
assert!(result.is_ok());
}
测试
lettre
测试需要本地监听端口 2525 的开放邮件服务器和 sendmail
命令。
行为准则
任何与 Lettre 互动的人,包括但不限于这个 GitHub 仓库,都必须遵守我们的 行为准则。
许可证
此程序根据 MIT 许可证分发。
有关详细信息,请参阅 LICENSE。
依赖项
~6MB
~89K SLoC