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 电子邮件

Download history 2759/week @ 2024-03-14 2678/week @ 2024-03-21 2387/week @ 2024-03-28 2449/week @ 2024-04-04 3283/week @ 2024-04-11 3835/week @ 2024-04-18 2735/week @ 2024-04-25 2208/week @ 2024-05-02 3519/week @ 2024-05-09 2800/week @ 2024-05-16 3576/week @ 2024-05-23 3243/week @ 2024-05-30 2713/week @ 2024-06-06 2594/week @ 2024-06-13 2728/week @ 2024-06-20 2290/week @ 2024-06-27

11,093 每月下载量
用于 少于 13 crates

MIT 许可证

510KB
11K SLoC

lettre

Lettre 是一个 Rust 邮件库。

Build Status Build status codecov

Crate Docs Required Rust version MIT licensed

Gitter Average time to resolve an issue Percentage of issues still open

有用链接


特性

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