Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mdecimus committed May 31, 2022
1 parent 8a4b893 commit 8c19e06
Show file tree
Hide file tree
Showing 23 changed files with 462 additions and 619 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
mail-send 0.2.0
================================
- Removed HTTP support.
- API cleanup.

mail-send 0.1.0
================================
- Initial release.
19 changes: 7 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "mail-send"
description = "E-mail delivery library with SMTP and DKIM support"
version = "0.1.0"
version = "0.2.0"
edition = "2018"
authors = [ "Stalwart Labs <hello@stalw.art>"]
license = "Apache-2.0 OR MIT"
Expand All @@ -21,22 +21,17 @@ rand = {version = "0.8.5", optional = true}
md5 = {version = "0.7.0", optional = true}
rsa = {version = "0.5", optional = true}
sha2 = {version = "0.9", optional = true}
tokio = { version = "1.16", features = ["net", "io-util", "time"], optional = true }
rustls = { version = "0.20", features = ["dangerous_configuration"], optional = true }
tokio-rustls = { version = "0.23.4", optional = true }
webpki-roots = { version = "0.22.3", optional = true }
gethostname = { version = "0.2.2", optional = true }
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "multipart"], optional = true}
serde = { version = "1.0", features = ["derive"], optional = true}
serde_json = { version = "1.0", optional = true}
tokio = { version = "1.16", features = ["net", "io-util", "time"]}
rustls = { version = "0.20", features = ["dangerous_configuration"]}
tokio-rustls = { version = "0.23.4"}
webpki-roots = { version = "0.22.3"}
gethostname = { version = "0.2.2"}

[dev-dependencies]
tokio = { version = "1.16", features = ["net", "io-util", "time", "rt-multi-thread", "macros"] }

[features]
default = [ "digest-md5", "cram-md5", "smtp", "dkim"]
smtp = ["tokio", "gethostname", "tokio-rustls", "webpki-roots", "rustls"]
http = ["reqwest", "serde", "serde_json"]
default = [ "digest-md5", "cram-md5", "dkim"]
digest-md5 = ["md5", "rand"]
cram-md5 = ["md5"]
dkim = ["rsa", "sha2"]
39 changes: 19 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@
[![docs.rs](https://img.shields.io/docsrs/mail-send)](https://docs.rs/mail-send)
[![crates.io](https://img.shields.io/crates/l/mail-send)](http://www.apache.org/licenses/LICENSE-2.0)

_mail-send_ is a Rust library to build, sign and send e-mail messages via SMTP or third party services such as Mailchimp, Mailgun, etc. It includes the following features:
_mail-send_ is a Rust library to build, sign and send e-mail messages via SMTP. It includes the following features:

- Generates **e-mail** messages conforming to the Internet Message Format standard (_RFC 5322_).
- Full **MIME** support (_RFC 2045 - 2049_) with automatic selection of the most optimal encoding for each message body part.
- DomainKeys Identified Mail (**DKIM**) Signatures (_RFC 6376_).
- **SMTP** support.
- Secure delivery over **TLS**.
- Authentication with automatic mechanism selection.
- Multiple authentication mechanisms:
- XOAUTH2
- CRAM-MD5
- DIGEST-MD5
- LOGIN
- PLAIN
- Third party e-mail delivery:
- Mailchimp
- Mailgun
- Others to follow.
- Simple Mail Transfer Protocol (**SMTP**; _RFC 5321_) delivery.
- SMTP Service Extension for Secure SMTP over **TLS** (_RFC 3207_).
- SMTP Service Extension for Authentication (_RFC 4954_) with automatic mechanism negotiation (from most secure to least secure):
- CRAM-MD5 (_RFC 2195_)
- DIGEST-MD5 (_RFC 2831_; obsolete but still supported)
- XOAUTH2 (Google proprietary)
- LOGIN
- PLAIN
- Full async (requires Tokio).

## Usage Example
Expand All @@ -43,7 +38,7 @@ Send a message via an SMTP server that requires authentication:

// Connect to an SMTP relay server over TLS and
// authenticate using the provided credentials.
SmtpClient::new("smtp.gmail.com")
Transport::new("smtp.gmail.com")
.credentials("john", "p4ssw0rd")
.connect_tls()
.await
Expand Down Expand Up @@ -74,7 +69,7 @@ Sign a message with DKIM and send it via an SMTP relay server:

// Connect to an SMTP relay server over TLS.
// Signs each message with the configured DKIM signer.
SmtpClient::new("smtp.example.com")
Transport::new("smtp.example.com")
.dkim(dkim)
.connect_tls()
.await
Expand All @@ -84,7 +79,7 @@ Sign a message with DKIM and send it via an SMTP relay server:
.unwrap();
```

Send a message via Mailchimp:
Send a message via an unsecured SMTP listening on port 2525. Mail-send will automatically upgrade the connection to TLS if the server advertises the STARTTLS extension:

```rust
// Build a simple multipart message
Expand All @@ -98,14 +93,18 @@ Send a message via Mailchimp:
.html_body("<h1>Hello, world!</h1>")
.text_body("Hello world!");

// Send the message via Mailchimp
MailchimpClient::new("YOUR_API_KEY")
// Send the message
Transport::new("unsecured.example.com")
.port(2525)
.connect()
.await
.unwrap()
.send(message)
.await
.unwrap();
```

More examples of how to build messages are available in the [`mail-builder`](https://crates.io/crates/mail-buikder) crate.
More examples of how to build messages are available in the [`mail-builder`](https://crates.io/crates/mail-builder) crate.
Please note that this library does not support parsing e-mail messages as this functionality is provided separately by the [`mail-parser`](https://crates.io/crates/mail-parser) crate.

## Testing
Expand Down
35 changes: 0 additions & 35 deletions examples/mailchimp.rs

This file was deleted.

35 changes: 0 additions & 35 deletions examples/mailgun.rs

This file was deleted.

4 changes: 2 additions & 2 deletions examples/smtp_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

use mail_builder::MessageBuilder;
use mail_send::smtp::client::SmtpClient;
use mail_send::Transport;

#[tokio::main]
async fn main() {
Expand All @@ -29,7 +29,7 @@ async fn main() {

// Connect to an SMTP relay server over TLS and
// authenticate using the provided credentials.
SmtpClient::new("smtp.gmail.com")
Transport::new("smtp.gmail.com")
.credentials("john", "p4ssw0rd")
.connect_tls()
.await
Expand Down
4 changes: 2 additions & 2 deletions examples/smtp_dkim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

use mail_builder::MessageBuilder;
use mail_send::smtp::{client::SmtpClient, dkim::DKIM};
use mail_send::{dkim::DKIM, Transport};

const TEST_KEY: &str = r#"-----BEGIN RSA PRIVATE KEY-----
MIICXwIBAAKBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkMoGeLnQg1fWn7/zYtIxN2SnFC
Expand Down Expand Up @@ -50,7 +50,7 @@ async fn main() {

// Connect to an SMTP relay server over TLS.
// Signs each message with the configured DKIM signer.
SmtpClient::new("smtp.gmail.com")
Transport::new("smtp.gmail.com")
.dkim(dkim)
.connect_tls()
.await
Expand Down
4 changes: 2 additions & 2 deletions examples/smtp_raw_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* except according to those terms.
*/

use mail_send::{message::Message, smtp::client::SmtpClient};
use mail_send::{smtp::message::Message, Transport};

#[tokio::main]
async fn main() {
Expand All @@ -22,7 +22,7 @@ async fn main() {

// Connect to an SMTP relay server.
// The library will upgrade the connection to TLS if the server supports it.
SmtpClient::new("mail.smtp2go.com")
Transport::new("mail.smtp2go.com")
.port(2525)
.connect()
.await
Expand Down
4 changes: 2 additions & 2 deletions examples/smtp_relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

use mail_builder::MessageBuilder;
use mail_send::smtp::client::SmtpClient;
use mail_send::Transport;

#[tokio::main]
async fn main() {
Expand All @@ -26,7 +26,7 @@ async fn main() {

// Connect to an SMTP relay server.
// The library will upgrade the connection to TLS if the server supports it.
SmtpClient::new("mail.smtp2go.com")
Transport::new("mail.smtp2go.com")
.port(2525)
.connect()
.await
Expand Down
4 changes: 2 additions & 2 deletions examples/smtp_tls_relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

use mail_builder::MessageBuilder;
use mail_send::smtp::client::SmtpClient;
use mail_send::Transport;

#[tokio::main]
async fn main() {
Expand All @@ -25,7 +25,7 @@ async fn main() {
.binary_attachment("image/png", "kittens.png", [1, 2, 3, 4].as_ref());

// Connect to an SMTP relay server over TLS
SmtpClient::new("smtp.gmail.com")
Transport::new("smtp.gmail.com")
.connect_tls()
.await
.unwrap()
Expand Down
Loading

0 comments on commit 8c19e06

Please sign in to comment.