From 3216a3f0b968352a0cdfeb27df657f7a220b1412 Mon Sep 17 00:00:00 2001
From: Alexis Mousset
Date: Sun, 20 Aug 2017 20:28:34 +0200
Subject: [PATCH] fix(doc): Update doc and specify the target version
---
README.md | 4 -
docs/getting-started/index.xml | 3 +-
docs/getting-started/intro/index.html | 5 +
docs/index.xml | 12 +-
docs/json/search.json | 10 +-
docs/sending-messages/file/index.html | 36 +++---
docs/sending-messages/index.xml | 9 +-
docs/sending-messages/sendmail/index.html | 23 ++--
docs/sending-messages/smtp/index.html | 125 +++++++++----------
docs/sending-messages/stub/index.html | 28 ++---
website/build.sh | 4 +
website/content/getting-started/intro.md | 5 +
website/content/sending-messages/file.md | 14 +--
website/content/sending-messages/sendmail.md | 12 +-
website/content/sending-messages/smtp.md | 70 ++++++-----
website/content/sending-messages/stub.md | 18 +--
16 files changed, 192 insertions(+), 186 deletions(-)
create mode 100755 website/build.sh
diff --git a/README.md b/README.md
index 9e28e31..e8b33ea 100644
--- a/README.md
+++ b/README.md
@@ -27,10 +27,6 @@ Released versions:
* [v0.6.0](https://docs.rs/lettre/0.6.0/lettre/)
* [v0.5.1](https://docs.rs/lettre/0.5.1/lettre/)
-Development version:
-
-* [master](https://lettre.github.io/lettre/master/lettre/)
-
## Install
This library requires rust 1.18 or newer.
diff --git a/docs/getting-started/index.xml b/docs/getting-started/index.xml
index 106ef3c..57e740a 100644
--- a/docs/getting-started/index.xml
+++ b/docs/getting-started/index.xml
@@ -17,7 +17,8 @@
Sun, 21 May 2017 23:46:17 +0200
https://lettre.github.io/lettre/getting-started/intro/
- Lettre is an email library that allows creating and sending messages. It provides:
+ This documentation is written for lettre 0.7, wich has not been released yet. Please use https://docs.rs/lettre/0.6.2/lettre/ for lettre 0.6.
+ Lettre is an email library that allows creating and sending messages. It provides:
An easy to use email builder Pluggable email transports Unicode support (for emails and transports, including for sender et recipient addresses when compatible) Secure defaults (emails are only sent encrypted by default)
diff --git a/docs/getting-started/intro/index.html b/docs/getting-started/intro/index.html
index 2dd4dac..771d8ba 100644
--- a/docs/getting-started/intro/index.html
+++ b/docs/getting-started/intro/index.html
@@ -268,6 +268,11 @@
Introduction
+
+
+
Lettre is an email library that allows creating and sending messages. It provides:
diff --git a/docs/index.xml b/docs/index.xml
index 2acc5b7..edb009b 100644
--- a/docs/index.xml
+++ b/docs/index.xml
@@ -17,7 +17,8 @@
Sun, 21 May 2017 23:46:17 +0200
https://lettre.github.io/lettre/getting-started/intro/
- Lettre is an email library that allows creating and sending messages. It provides:
+ This documentation is written for lettre 0.7, wich has not been released yet. Please use https://docs.rs/lettre/0.6.2/lettre/ for lettre 0.6.
+ Lettre is an email library that allows creating and sending messages. It provides:
An easy to use email builder Pluggable email transports Unicode support (for emails and transports, including for sender et recipient addresses when compatible) Secure defaults (emails are only sent encrypted by default)
@@ -51,7 +52,7 @@ The relay server can be the local email server, a specific host or a third-party
https://lettre.github.io/lettre/sending-messages/sendmail/
The sendmail transport sends the email using the local sendmail command.
-uselettre::sendmail::SendmailTransport; uselettre::{SimpleSendableEmail, EmailTransport}; letemail =SimpleSendableEmail::new( "user@localhost", vec!["root@localhost"], "message_id", "Hello world" ); letmutsender =SendmailTransport::new(); letresult =sender.send(email); assert!(result.is_ok());
+use lettre::sendmail::SendmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; let email = SimpleSendableEmail::new( EmailAddress::new("user@localhost".to_string()), vec![EmailAddress::new("root@localhost".to_string())], "message_id".to_string(), "Hello world".to_string(), ); let mut sender = SendmailTransport::new(); let result = sender.send(&email); assert!(result.is_ok());
-
@@ -61,8 +62,7 @@ uselettre::sendmail::SendmailTransport; uselettre::{SimpleSendableEmail, EmailTr
https://lettre.github.io/lettre/sending-messages/file/
The file transport writes the emails to the given directory. The name of the file will be message_id.txt. It can be useful for testing purposes, or if you want to keep track of sent messages.
-usestd::env::temp_dir; uselettre::file::FileEmailTransport; uselettre::{SimpleSendableEmail, EmailTransport}; // Write to the local temp directory letmutsender =FileEmailTransport::new(temp_dir()); letemail =SimpleSendableEmail::new( "user@localhost", vec!["root@localhost"], "message_id", "Hello world" ); letresult =sender.send(email); assert!(result.is_ok()); Example result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt:
-b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost> To: <root@localhost> From: <user@localhost> Subject: Hello Date: Sat, 31 Oct 2015 13:42:19 +0100 Message-ID: <b7c211bc-9811-45ce-8cd9-68eab575d695.
+use std::env::temp_dir; use lettre::file::FileEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; // Write to the local temp directory let mut sender = FileEmailTransport::new(temp_dir()); let email = SimpleSendableEmail::new( EmailAddress::new("user@localhost".to_string()), vec![EmailAddress::new("root@localhost".to_string())], "message_id".to_string(), "Hello world".to_string(), ); let result = sender.send(&email); assert!(result.is_ok()); Example result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.
-
@@ -72,8 +72,8 @@ b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=&am
https://lettre.github.io/lettre/sending-messages/stub/
The stub transport only logs message envelope and drops the content. It can be useful for testing purposes.
-uselettre::stub::StubEmailTransport; uselettre::{SimpleSendableEmail, EmailTransport}; letemail =SimpleSendableEmail::new( "user@localhost", vec!["root@localhost"], "message_id", "Hello world" ); letmutsender =StubEmailTransport; letresult =sender.send(email); assert!(result.is_ok()); Will log the line:
-b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost>
+use lettre::stub::StubEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; let email = SimpleSendableEmail::new( EmailAddress::new("user@localhost".to_string()), vec![EmailAddress::new("root@localhost".to_string())], "message_id".to_string(), "Hello world".to_string(), ); let mut sender = StubEmailTransport::new_positive(); let result = sender.send(&email); assert!(result.is_ok()); Will log (when using a logger like env_logger):
+b7c211bc-9811-45ce-8cd9-68eab575d695: from= to=
diff --git a/docs/json/search.json b/docs/json/search.json
index cbb4915..4ee5dd9 100644
--- a/docs/json/search.json
+++ b/docs/json/search.json
@@ -14,7 +14,7 @@
{
"uri": "/content/getting-started/intro",
"title": "Introduction",
- "content": "\nLettre is an email library that allows creating and sending messages. It provides:\n\nAn easy to use email builder\nPluggable email transports\nUnicode support (for emails and transports, including for sender et recipient addresses when compatible)\nSecure defaults (emails are only sent encrypted by default)\n",
+ "content": "\n{{% notice note %}}\nThis documentation is written for lettre 0.7, wich has not been released yet.\nPlease use https://docs.rs/lettre/0.6.2/lettre/ for lettre 0.6.\n{{% /notice%}}\n\nLettre is an email library that allows creating and sending messages. It provides:\n\nAn easy to use email builder\nPluggable email transports\nUnicode support (for emails and transports, including for sender et recipient addresses when compatible)\nSecure defaults (emails are only sent encrypted by default)\n",
"tags": []
},
{
@@ -26,7 +26,7 @@
{
"uri": "/content/sending-messages/file",
"title": "File transport",
- "content": "\nThe file transport writes the emails to the given directory. The name of the file will be\nmessage_id.txt.\nIt can be useful for testing purposes, or if you want to keep track of sent messages.\n\nuse std::env::temp_dir;\n\nuse lettre::file::FileEmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport};\n\n// Write to the local temp directory\nlet mut sender = FileEmailTransport::new(temp_dir());\nlet email = SimpleSendableEmail::new(\n \"user@localhost\",\n vec![\"root@localhost\"],\n \"message_id\",\n \"Hello world\"\n );\n\nlet result = sender.send(email);\nassert!(result.is_ok());\n\nExample result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt:\n\nb7c211bc-9811-45ce-8cd9-68eab575d695: from=user@localhost to=root@localhost\nTo: root@localhost\nFrom: user@localhost\nSubject: Hello\nDate: Sat, 31 Oct 2015 13:42:19 +0100\nMessage-ID: b7c211bc-9811-45ce-8cd9-68eab575d695.lettre@localhost\n\nHello World!\n",
+ "content": "\nThe file transport writes the emails to the given directory. The name of the file will be\nmessage_id.txt.\nIt can be useful for testing purposes, or if you want to keep track of sent messages.\n\nuse std::env::temp_dir;\n\nuse lettre::file::FileEmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};\n\n// Write to the local temp directory\nlet mut sender = FileEmailTransport::new(temp_dir());\nlet email = SimpleSendableEmail::new(\n EmailAddress::new(\"user@localhost\".to_string()),\n vec![EmailAddress::new(\"root@localhost\".to_string())],\n \"messageid\".tostring(),\n \"Hello world\".to_string(),\n );\n\nlet result = sender.send(&email);\nassert!(result.is_ok());\n\nExample result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt:\n\nb7c211bc-9811-45ce-8cd9-68eab575d695: from=user@localhost to=root@localhost\nTo: root@localhost\nFrom: user@localhost\nSubject: Hello\nDate: Sat, 31 Oct 2015 13:42:19 +0100\nMessage-ID: b7c211bc-9811-45ce-8cd9-68eab575d695.lettre@localhost\n\nHello World!\n",
"tags": []
},
{
@@ -38,19 +38,19 @@
{
"uri": "/content/sending-messages/sendmail",
"title": "Sendmail transport",
- "content": "\nThe sendmail transport sends the email using the local sendmail command.\n\nuse lettre::sendmail::SendmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport};\n\nlet email = SimpleSendableEmail::new(\n \"user@localhost\",\n vec![\"root@localhost\"],\n \"message_id\",\n \"Hello world\"\n );\n\nlet mut sender = SendmailTransport::new();\nlet result = sender.send(email);\nassert!(result.is_ok());\n",
+ "content": "\nThe sendmail transport sends the email using the local sendmail command.\n\nuse lettre::sendmail::SendmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};\n\nlet email = SimpleSendableEmail::new(\n EmailAddress::new(\"user@localhost\".to_string()),\n vec![EmailAddress::new(\"root@localhost\".to_string())],\n \"messageid\".tostring(),\n \"Hello world\".to_string(),\n );\n\nlet mut sender = SendmailTransport::new();\nlet result = sender.send(&email);\nassert!(result.is_ok());\n",
"tags": []
},
{
"uri": "/content/sending-messages/smtp",
"title": "SMTP transport",
- "content": "\nThis transport uses the SMTP protocol to send emails over the network (locally or remotely).\n\nIt is desinged to be:\n\nSecured: email are encrypted by default\nModern: Unicode support for email content and sender/recipient adresses when compatible\nFast: supports tcp connection reuse\n\nThis client is designed to send emails to a relay server, and should not be used to send\nemails directly to the destination.\n\nThe relay server can be the local email server, a specific host or a third-party service.\n\nSimple example\n\nThis is the most basic example of usage:\n\nuse lettre::{SimpleSendableEmail, EmailTransport};\nuse lettre::smtp::SmtpTransportBuilder;\nuse lettre::smtp::SecurityLevel;\n\nlet email = SimpleSendableEmail::new(\n \"user@localhost\",\n vec![\"root@localhost\"],\n \"message_id\",\n \"Hello world\"\n );\n\n// Open a local connection on port 25\nlet mut mailer =\nSmtpTransportBuilder::localhost().unwrap().security_level(SecurityLevel::Opportunistic).build();\n// Send the email\nlet result = mailer.send(email);\n\nassert!(result.is_ok());\n\n Complete example\n\nuse lettre::smtp::{SecurityLevel, SmtpTransport,\nSmtpTransportBuilder};\nuse lettre::smtp::authentication::Mechanism;\nuse lettre::smtp::SUBMISSION_PORT;\nuse lettre::{SimpleSendableEmail, EmailTransport};\n\nlet email = SimpleSendableEmail::new(\n \"user@localhost\",\n vec![\"root@localhost\"],\n \"message_id\",\n \"Hello world\"\n );\n\n// Connect to a remote server on a custom port\nlet mut mailer = SmtpTransportBuilder::new((\"server.tld\",\nSUBMISSION_PORT)).unwrap()\n // Set the name sent during EHLO/HELO, default is localhost\n .hello_name(\"my.hostname.tld\")\n // Add credentials for authentication\n .credentials(\"username\", \"password\")\n // Specify a TLS security level. You can also specify an SslContext with\n // .ssl_context(SslContext::Ssl23)\n .security_level(SecurityLevel::AlwaysEncrypt)\n // Enable SMTPUTF8 if the server supports it\n .smtp_utf8(true)\n // Configure expected authentication mechanism\n .authentication_mechanism(Mechanism::CramMd5)\n // Enable connection reuse\n .connection_reuse(true).build();\n\nlet result_1 = mailer.send(email.clone());\nassert!(result1.isok());\n\n// The second email will use the same connection\nlet result_2 = mailer.send(email);\nassert!(result2.isok());\n\n// Explicitly close the SMTP transaction as we enabled connection reuse\nmailer.close();\n\nLower level\n\nYou can also send commands, here is a simple email transaction without\nerror handling:\n\nuse lettre::smtp::SMTP_PORT;\nuse lettre::smtp::client::Client;\nuse lettre::smtp::client::net::NetworkStream;\n\nlet mut email_client: ClientNetworkStream = Client::new();\nlet _ = emailclient.connect(&(\"localhost\", SMTPPORT), None);\nlet _ = emailclient.ehlo(\"myhostname\");\nlet _ = email_client.mail(\"user@example.com\", None);\nlet _ = email_client.rcpt(\"user@example.org\");\nlet _ = email_client.data();\nlet _ = email_client.message(\"Test email\");\nlet _ = email_client.quit();\n\n",
+ "content": "\nThis transport uses the SMTP protocol to send emails over the network (locally or remotely).\n\nIt is desinged to be:\n\nSecured: email are encrypted by default\nModern: Unicode support for email content and sender/recipient adresses when compatible\nFast: supports tcp connection reuse\n\nThis client is designed to send emails to a relay server, and should not be used to send\nemails directly to the destination.\n\nThe relay server can be the local email server, a specific host or a third-party service.\n\nSimple example\n\nThis is the most basic example of usage:\n\nuse lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};\n\nlet email = SimpleSendableEmail::new(\n EmailAddress::new(\"user@localhost\".to_string()),\n vec![EmailAddress::new(\"root@localhost\".to_string())],\n \"messageid\".tostring(),\n \"Hello world\".to_string(),\n );\n\n// Open a local connection on port 25\nlet mut mailer =\nSmtpTransport::builderunencryptedlocalhost().unwrap().build();\n// Send the email\nlet result = mailer.send(&email);\n\nassert!(result.is_ok());\n\n Complete example\n\nuse lettre::smtp::authentication::{Credentials, Mechanism};\nuse lettre::smtp::SUBMISSION_PORT;\nuse lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};\nuse lettre::smtp::extension::ClientId;\nuse lettre::smtp::ConnectionReuseParameters;\n\nlet email = SimpleSendableEmail::new(\n EmailAddress::new(\"user@localhost\".to_string()),\n vec![EmailAddress::new(\"root@localhost\".to_string())],\n \"messageid\".tostring(),\n \"Hello world\".to_string(),\n );\n\n// Connect to a remote server on a custom port\nlet mut mailer = SmtpTransport::simplebuilder(\"server.tld\".tostring()).unwrap()\n // Set the name sent during EHLO/HELO, default is localhost\n .helloname(ClientId::Domain(\"my.hostname.tld\".tostring()))\n // Add credentials for authentication\n .credentials(Credentials::new(\"username\".tostring(), \"password\".tostring()))\n // Enable SMTPUTF8 if the server supports it\n .smtp_utf8(true)\n // Configure expected authentication mechanism\n .authentication_mechanism(Mechanism::Plain)\n // Enable connection reuse\n .connection_reuse(ConnectionReuseParameters::ReuseUnlimited).build();\n\nlet result_1 = mailer.send(&email);\nassert!(result1.isok());\n\n// The second email will use the same connection\nlet result_2 = mailer.send(&email);\nassert!(result2.isok());\n\n// Explicitly close the SMTP transaction as we enabled connection reuse\nmailer.close();\n\nLower level\n\nYou can also send commands, here is a simple email transaction without\nerror handling:\n\nuse lettre::EmailAddress;\nuse lettre::smtp::SMTP_PORT;\nuse lettre::smtp::client::Client;\nuse lettre::smtp::client::net::NetworkStream;\nuse lettre::smtp::extension::ClientId;\nuse lettre::smtp::commands::*;\n\nlet mut email_client: ClientNetworkStream = Client::new();\nlet _ = emailclient.connect(&(\"localhost\", SMTPPORT), None);\nlet _ = emailclient.smtpcommand(EhloCommand::new(ClientId::new(\"myhostname\".tostring())));\nlet _ = emailclient.smtpcommand(\n MailCommand::new(Some(EmailAddress::new(\"user@example.com\".to_string())), vec![])\n );\nlet _ = emailclient.smtpcommand(\n RcptCommand::new(EmailAddress::new(\"user@example.org\".to_string()), vec![])\n );\nlet _ = emailclient.smtpcommand(DataCommand);\nlet _ = emailclient.message(Box::new(\"Test email\".asbytes()));\nlet _ = emailclient.smtpcommand(QuitCommand);\n\n",
"tags": []
},
{
"uri": "/content/sending-messages/stub",
"title": "Stub transport",
- "content": "\nThe stub transport only logs message envelope and drops the content. It can be useful for\ntesting purposes.\n\nuse lettre::stub::StubEmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport};\n\nlet email = SimpleSendableEmail::new(\n \"user@localhost\",\n vec![\"root@localhost\"],\n \"message_id\",\n \"Hello world\"\n );\n\nlet mut sender = StubEmailTransport;\nlet result = sender.send(email);\nassert!(result.is_ok());\n\nWill log the line:\n\nb7c211bc-9811-45ce-8cd9-68eab575d695: from=user@localhost to=root@localhost\n`",
+ "content": "\nThe stub transport only logs message envelope and drops the content. It can be useful for\ntesting purposes.\n\nuse lettre::stub::StubEmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};\n\nlet email = SimpleSendableEmail::new(\n EmailAddress::new(\"user@localhost\".to_string()),\n vec![EmailAddress::new(\"root@localhost\".to_string())],\n \"messageid\".tostring(),\n \"Hello world\".to_string(),\n );\n\nlet mut sender = StubEmailTransport::new_positive();\nlet result = sender.send(&email);\nassert!(result.is_ok());\n\nWill log (when using a logger like env_logger):\n\nb7c211bc-9811-45ce-8cd9-68eab575d695: from=user@localhost to=root@localhost\n",
"tags": []
}
]
\ No newline at end of file
diff --git a/docs/sending-messages/file/index.html b/docs/sending-messages/file/index.html
index c758f04..eb0a9f3 100644
--- a/docs/sending-messages/file/index.html
+++ b/docs/sending-messages/file/index.html
@@ -271,34 +271,32 @@
The file transport writes the emails to the given directory. The name of the file will be
message_id.txt.
It can be useful for testing purposes, or if you want to keep track of sent messages.
-use std::env::temp_dir;
+use std::env::temp_dir;
-use lettre::file::FileEmailTransport;
-use lettre::{SimpleSendableEmail, EmailTransport};
+use lettre::file::FileEmailTransport;
+use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
-// Write to the local temp directory
-let mut sender = FileEmailTransport::new(temp_dir());
-let email = SimpleSendableEmail::new(
- "user@localhost",
- vec!["root@localhost"],
- "message_id",
- "Hello world"
- );
+// Write to the local temp directory
+let mut sender = FileEmailTransport::new(temp_dir());
+let email = SimpleSendableEmail::new(
+ EmailAddress::new("user@localhost".to_string()),
+ vec![EmailAddress::new("root@localhost".to_string())],
+ "message_id".to_string(),
+ "Hello world".to_string(),
+ );
-let result = sender.send(email);
-assert!(result.is_ok());
-
+let result = sender.send(&email);
+assert!(result.is_ok());
Example result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt:
-b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost>
-To: <root@localhost>
-From: <user@localhost>
+b7c211bc-9811-45ce-8cd9-68eab575d695: from= to=
+To:
+From:
Subject: Hello
Date: Sat, 31 Oct 2015 13:42:19 +0100
-Message-ID: <b7c211bc-9811-45ce-8cd9-68eab575d695.lettre@localhost>
+Message-ID:
Hello World!
-
diff --git a/docs/sending-messages/index.xml b/docs/sending-messages/index.xml
index 1566aaf..b983558 100644
--- a/docs/sending-messages/index.xml
+++ b/docs/sending-messages/index.xml
@@ -41,7 +41,7 @@ The relay server can be the local email server, a specific host or a third-party
https://lettre.github.io/lettre/sending-messages/sendmail/
The sendmail transport sends the email using the local sendmail command.
-uselettre::sendmail::SendmailTransport; uselettre::{SimpleSendableEmail, EmailTransport}; letemail =SimpleSendableEmail::new( "user@localhost", vec!["root@localhost"], "message_id", "Hello world" ); letmutsender =SendmailTransport::new(); letresult =sender.send(email); assert!(result.is_ok());
+use lettre::sendmail::SendmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; let email = SimpleSendableEmail::new( EmailAddress::new("user@localhost".to_string()), vec![EmailAddress::new("root@localhost".to_string())], "message_id".to_string(), "Hello world".to_string(), ); let mut sender = SendmailTransport::new(); let result = sender.send(&email); assert!(result.is_ok());
-
@@ -51,8 +51,7 @@ uselettre::sendmail::SendmailTransport; uselettre::{SimpleSendableEmail, EmailTr
https://lettre.github.io/lettre/sending-messages/file/
The file transport writes the emails to the given directory. The name of the file will be message_id.txt. It can be useful for testing purposes, or if you want to keep track of sent messages.
-usestd::env::temp_dir; uselettre::file::FileEmailTransport; uselettre::{SimpleSendableEmail, EmailTransport}; // Write to the local temp directory letmutsender =FileEmailTransport::new(temp_dir()); letemail =SimpleSendableEmail::new( "user@localhost", vec!["root@localhost"], "message_id", "Hello world" ); letresult =sender.send(email); assert!(result.is_ok()); Example result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt:
-b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost> To: <root@localhost> From: <user@localhost> Subject: Hello Date: Sat, 31 Oct 2015 13:42:19 +0100 Message-ID: <b7c211bc-9811-45ce-8cd9-68eab575d695.
+use std::env::temp_dir; use lettre::file::FileEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; // Write to the local temp directory let mut sender = FileEmailTransport::new(temp_dir()); let email = SimpleSendableEmail::new( EmailAddress::new("user@localhost".to_string()), vec![EmailAddress::new("root@localhost".to_string())], "message_id".to_string(), "Hello world".to_string(), ); let result = sender.send(&email); assert!(result.is_ok()); Example result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.
-
@@ -62,8 +61,8 @@ b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=&am
https://lettre.github.io/lettre/sending-messages/stub/
The stub transport only logs message envelope and drops the content. It can be useful for testing purposes.
-uselettre::stub::StubEmailTransport; uselettre::{SimpleSendableEmail, EmailTransport}; letemail =SimpleSendableEmail::new( "user@localhost", vec!["root@localhost"], "message_id", "Hello world" ); letmutsender =StubEmailTransport; letresult =sender.send(email); assert!(result.is_ok()); Will log the line:
-b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost>
+use lettre::stub::StubEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; let email = SimpleSendableEmail::new( EmailAddress::new("user@localhost".to_string()), vec![EmailAddress::new("root@localhost".to_string())], "message_id".to_string(), "Hello world".to_string(), ); let mut sender = StubEmailTransport::new_positive(); let result = sender.send(&email); assert!(result.is_ok()); Will log (when using a logger like env_logger):
+b7c211bc-9811-45ce-8cd9-68eab575d695: from= to=
diff --git a/docs/sending-messages/sendmail/index.html b/docs/sending-messages/sendmail/index.html
index be272ea..40a65fb 100644
--- a/docs/sending-messages/sendmail/index.html
+++ b/docs/sending-messages/sendmail/index.html
@@ -269,20 +269,19 @@
The sendmail transport sends the email using the local sendmail command.
-use lettre::sendmail::SendmailTransport;
-use lettre::{SimpleSendableEmail, EmailTransport};
+use lettre::sendmail::SendmailTransport;
+use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
-let email = SimpleSendableEmail::new(
- "user@localhost",
- vec!["root@localhost"],
- "message_id",
- "Hello world"
- );
+let email = SimpleSendableEmail::new(
+ EmailAddress::new("user@localhost".to_string()),
+ vec![EmailAddress::new("root@localhost".to_string())],
+ "message_id".to_string(),
+ "Hello world".to_string(),
+ );
-let mut sender = SendmailTransport::new();
-let result = sender.send(email);
-assert!(result.is_ok());
-
+let mut sender = SendmailTransport::new();
+let result = sender.send(&email);
+assert!(result.is_ok());
diff --git a/docs/sending-messages/smtp/index.html b/docs/sending-messages/smtp/index.html
index f9aff72..a206a61 100644
--- a/docs/sending-messages/smtp/index.html
+++ b/docs/sending-messages/smtp/index.html
@@ -303,85 +303,84 @@ emails directly to the destination.
Simple example
This is the most basic example of usage:
-use lettre::{SimpleSendableEmail, EmailTransport};
-use lettre::smtp::SmtpTransportBuilder;
-use lettre::smtp::SecurityLevel;
+use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};
-let email = SimpleSendableEmail::new(
- "user@localhost",
- vec!["root@localhost"],
- "message_id",
- "Hello world"
- );
+let email = SimpleSendableEmail::new(
+ EmailAddress::new("user@localhost".to_string()),
+ vec![EmailAddress::new("root@localhost".to_string())],
+ "message_id".to_string(),
+ "Hello world".to_string(),
+ );
-// Open a local connection on port 25
-let mut mailer =
-SmtpTransportBuilder::localhost().unwrap().security_level(SecurityLevel::Opportunistic).build();
-// Send the email
-let result = mailer.send(email);
+// Open a local connection on port 25
+let mut mailer =
+SmtpTransport::builder_unencrypted_localhost().unwrap().build();
+// Send the email
+let result = mailer.send(&email);
-assert!(result.is_ok());
-
+assert!(result.is_ok());
Complete example
-use lettre::smtp::{SecurityLevel, SmtpTransport,
-SmtpTransportBuilder};
-use lettre::smtp::authentication::Mechanism;
-use lettre::smtp::SUBMISSION_PORT;
-use lettre::{SimpleSendableEmail, EmailTransport};
+use lettre::smtp::authentication::{Credentials, Mechanism};
+use lettre::smtp::SUBMISSION_PORT;
+use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};
+use lettre::smtp::extension::ClientId;
+use lettre::smtp::ConnectionReuseParameters;
-let email = SimpleSendableEmail::new(
- "user@localhost",
- vec!["root@localhost"],
- "message_id",
- "Hello world"
- );
-// Connect to a remote server on a custom port
-let mut mailer = SmtpTransportBuilder::new(("server.tld",
-SUBMISSION_PORT)).unwrap()
- // Set the name sent during EHLO/HELO, default is `localhost`
- .hello_name("my.hostname.tld")
- // Add credentials for authentication
- .credentials("username", "password")
- // Specify a TLS security level. You can also specify an SslContext with
- // .ssl_context(SslContext::Ssl23)
- .security_level(SecurityLevel::AlwaysEncrypt)
- // Enable SMTPUTF8 if the server supports it
- .smtp_utf8(true)
- // Configure expected authentication mechanism
- .authentication_mechanism(Mechanism::CramMd5)
- // Enable connection reuse
- .connection_reuse(true).build();
+let email = SimpleSendableEmail::new(
+ EmailAddress::new("user@localhost".to_string()),
+ vec![EmailAddress::new("root@localhost".to_string())],
+ "message_id".to_string(),
+ "Hello world".to_string(),
+ );
-let result_1 = mailer.send(email.clone());
-assert!(result_1.is_ok());
+// Connect to a remote server on a custom port
+let mut mailer = SmtpTransport::simple_builder("server.tld".to_string()).unwrap()
+ // Set the name sent during EHLO/HELO, default is `localhost`
+ .hello_name(ClientId::Domain("my.hostname.tld".to_string()))
+ // Add credentials for authentication
+ .credentials(Credentials::new("username".to_string(), "password".to_string()))
+ // Enable SMTPUTF8 if the server supports it
+ .smtp_utf8(true)
+ // Configure expected authentication mechanism
+ .authentication_mechanism(Mechanism::Plain)
+ // Enable connection reuse
+ .connection_reuse(ConnectionReuseParameters::ReuseUnlimited).build();
-// The second email will use the same connection
-let result_2 = mailer.send(email);
-assert!(result_2.is_ok());
+let result_1 = mailer.send(&email);
+assert!(result_1.is_ok());
-// Explicitly close the SMTP transaction as we enabled connection reuse
-mailer.close();
-
+// The second email will use the same connection
+let result_2 = mailer.send(&email);
+assert!(result_2.is_ok());
+
+// Explicitly close the SMTP transaction as we enabled connection reuse
+mailer.close();
Lower level
You can also send commands, here is a simple email transaction without
error handling:
-use lettre::smtp::SMTP_PORT;
-use lettre::smtp::client::Client;
-use lettre::smtp::client::net::NetworkStream;
+use lettre::EmailAddress;
+use lettre::smtp::SMTP_PORT;
+use lettre::smtp::client::Client;
+use lettre::smtp::client::net::NetworkStream;
+use lettre::smtp::extension::ClientId;
+use lettre::smtp::commands::*;
-let mut email_client: Client<NetworkStream> = Client::new();
-let _ = email_client.connect(&("localhost", SMTP_PORT), None);
-let _ = email_client.ehlo("my_hostname");
-let _ = email_client.mail("user@example.com", None);
-let _ = email_client.rcpt("user@example.org");
-let _ = email_client.data();
-let _ = email_client.message("Test email");
-let _ = email_client.quit();
-
+let mut email_client: Client = Client::new();
+let _ = email_client.connect(&("localhost", SMTP_PORT), None);
+let _ = email_client.smtp_command(EhloCommand::new(ClientId::new("my_hostname".to_string())));
+let _ = email_client.smtp_command(
+ MailCommand::new(Some(EmailAddress::new("user@example.com".to_string())), vec![])
+ );
+let _ = email_client.smtp_command(
+ RcptCommand::new(EmailAddress::new("user@example.org".to_string()), vec![])
+ );
+let _ = email_client.smtp_command(DataCommand);
+let _ = email_client.message(Box::new("Test email".as_bytes()));
+let _ = email_client.smtp_command(QuitCommand);
diff --git a/docs/sending-messages/stub/index.html b/docs/sending-messages/stub/index.html
index 4cdeb00..cbd5f71 100644
--- a/docs/sending-messages/stub/index.html
+++ b/docs/sending-messages/stub/index.html
@@ -270,24 +270,22 @@
The stub transport only logs message envelope and drops the content. It can be useful for
testing purposes.
-use lettre::stub::StubEmailTransport;
-use lettre::{SimpleSendableEmail, EmailTransport};
+use lettre::stub::StubEmailTransport;
+use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
-let email = SimpleSendableEmail::new(
- "user@localhost",
- vec!["root@localhost"],
- "message_id",
- "Hello world"
- );
+let email = SimpleSendableEmail::new(
+ EmailAddress::new("user@localhost".to_string()),
+ vec![EmailAddress::new("root@localhost".to_string())],
+ "message_id".to_string(),
+ "Hello world".to_string(),
+ );
-let mut sender = StubEmailTransport;
-let result = sender.send(email);
-assert!(result.is_ok());
-
+let mut sender = StubEmailTransport::new_positive();
+let result = sender.send(&email);
+assert!(result.is_ok());
-Will log the line:
-b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost>
-
+Will log (when using a logger like env_logger):
+b7c211bc-9811-45ce-8cd9-68eab575d695: from= to=
diff --git a/website/build.sh b/website/build.sh
new file mode 100755
index 0000000..a726ab0
--- /dev/null
+++ b/website/build.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+hugo
+lunr-hugo -i "content/**/*.md" -o ../docs/json/search.json -l toml
+
diff --git a/website/content/getting-started/intro.md b/website/content/getting-started/intro.md
index f8aa3b7..980c5c4 100644
--- a/website/content/getting-started/intro.md
+++ b/website/content/getting-started/intro.md
@@ -6,6 +6,11 @@ weight = 1
+++
+{{% notice note %}}
+This documentation is written for lettre 0.7, wich has not been released yet.
+Please use https://docs.rs/lettre/0.6.2/lettre/ for lettre 0.6.
+{{% /notice%}}
+
Lettre is an email library that allows creating and sending messages. It provides:
* An easy to use email builder
diff --git a/website/content/sending-messages/file.md b/website/content/sending-messages/file.md
index 2f66745..baa59bf 100644
--- a/website/content/sending-messages/file.md
+++ b/website/content/sending-messages/file.md
@@ -10,22 +10,22 @@ The file transport writes the emails to the given directory. The name of the fil
`message_id.txt`.
It can be useful for testing purposes, or if you want to keep track of sent messages.
-``` rust
+```rust
use std::env::temp_dir;
use lettre::file::FileEmailTransport;
-use lettre::{SimpleSendableEmail, EmailTransport};
+use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
// Write to the local temp directory
let mut sender = FileEmailTransport::new(temp_dir());
let email = SimpleSendableEmail::new(
- "user@localhost",
- vec!["root@localhost"],
- "message_id",
- "Hello world"
+ EmailAddress::new("user@localhost".to_string()),
+ vec![EmailAddress::new("root@localhost".to_string())],
+ "message_id".to_string(),
+ "Hello world".to_string(),
);
-let result = sender.send(email);
+let result = sender.send(&email);
assert!(result.is_ok());
```
diff --git a/website/content/sending-messages/sendmail.md b/website/content/sending-messages/sendmail.md
index b743c7f..ff19e04 100644
--- a/website/content/sending-messages/sendmail.md
+++ b/website/content/sending-messages/sendmail.md
@@ -10,16 +10,16 @@ The sendmail transport sends the email using the local sendmail command.
``` rust
use lettre::sendmail::SendmailTransport;
-use lettre::{SimpleSendableEmail, EmailTransport};
+use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
let email = SimpleSendableEmail::new(
- "user@localhost",
- vec!["root@localhost"],
- "message_id",
- "Hello world"
+ EmailAddress::new("user@localhost".to_string()),
+ vec![EmailAddress::new("root@localhost".to_string())],
+ "message_id".to_string(),
+ "Hello world".to_string(),
);
let mut sender = SendmailTransport::new();
-let result = sender.send(email);
+let result = sender.send(&email);
assert!(result.is_ok());
```
diff --git a/website/content/sending-messages/smtp.md b/website/content/sending-messages/smtp.md
index 4cd1dd9..b186ac0 100644
--- a/website/content/sending-messages/smtp.md
+++ b/website/content/sending-messages/smtp.md
@@ -24,22 +24,20 @@ The relay server can be the local email server, a specific host or a third-party
This is the most basic example of usage:
``` rust
-use lettre::{SimpleSendableEmail, EmailTransport};
-use lettre::smtp::SmtpTransportBuilder;
-use lettre::smtp::SecurityLevel;
+use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};
let email = SimpleSendableEmail::new(
- "user@localhost",
- vec!["root@localhost"],
- "message_id",
- "Hello world"
+ EmailAddress::new("user@localhost".to_string()),
+ vec![EmailAddress::new("root@localhost".to_string())],
+ "message_id".to_string(),
+ "Hello world".to_string(),
);
// Open a local connection on port 25
let mut mailer =
-SmtpTransportBuilder::localhost().unwrap().security_level(SecurityLevel::Opportunistic).build();
+SmtpTransport::builder_unencrypted_localhost().unwrap().build();
// Send the email
-let result = mailer.send(email);
+let result = mailer.send(&email);
assert!(result.is_ok());
```
@@ -47,41 +45,38 @@ assert!(result.is_ok());
#### Complete example
``` rust
-use lettre::smtp::{SecurityLevel, SmtpTransport,
-SmtpTransportBuilder};
-use lettre::smtp::authentication::Mechanism;
+use lettre::smtp::authentication::{Credentials, Mechanism};
use lettre::smtp::SUBMISSION_PORT;
-use lettre::{SimpleSendableEmail, EmailTransport};
+use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};
+use lettre::smtp::extension::ClientId;
+use lettre::smtp::ConnectionReuseParameters;
+
let email = SimpleSendableEmail::new(
- "user@localhost",
- vec!["root@localhost"],
- "message_id",
- "Hello world"
+ EmailAddress::new("user@localhost".to_string()),
+ vec![EmailAddress::new("root@localhost".to_string())],
+ "message_id".to_string(),
+ "Hello world".to_string(),
);
// Connect to a remote server on a custom port
-let mut mailer = SmtpTransportBuilder::new(("server.tld",
-SUBMISSION_PORT)).unwrap()
+let mut mailer = SmtpTransport::simple_builder("server.tld".to_string()).unwrap()
// Set the name sent during EHLO/HELO, default is `localhost`
- .hello_name("my.hostname.tld")
+ .hello_name(ClientId::Domain("my.hostname.tld".to_string()))
// Add credentials for authentication
- .credentials("username", "password")
- // Specify a TLS security level. You can also specify an SslContext with
- // .ssl_context(SslContext::Ssl23)
- .security_level(SecurityLevel::AlwaysEncrypt)
+ .credentials(Credentials::new("username".to_string(), "password".to_string()))
// Enable SMTPUTF8 if the server supports it
.smtp_utf8(true)
// Configure expected authentication mechanism
- .authentication_mechanism(Mechanism::CramMd5)
+ .authentication_mechanism(Mechanism::Plain)
// Enable connection reuse
- .connection_reuse(true).build();
+ .connection_reuse(ConnectionReuseParameters::ReuseUnlimited).build();
-let result_1 = mailer.send(email.clone());
+let result_1 = mailer.send(&email);
assert!(result_1.is_ok());
// The second email will use the same connection
-let result_2 = mailer.send(email);
+let result_2 = mailer.send(&email);
assert!(result_2.is_ok());
// Explicitly close the SMTP transaction as we enabled connection reuse
@@ -94,17 +89,24 @@ You can also send commands, here is a simple email transaction without
error handling:
``` rust
+use lettre::EmailAddress;
use lettre::smtp::SMTP_PORT;
use lettre::smtp::client::Client;
use lettre::smtp::client::net::NetworkStream;
+use lettre::smtp::extension::ClientId;
+use lettre::smtp::commands::*;
let mut email_client: Client = Client::new();
let _ = email_client.connect(&("localhost", SMTP_PORT), None);
-let _ = email_client.ehlo("my_hostname");
-let _ = email_client.mail("user@example.com", None);
-let _ = email_client.rcpt("user@example.org");
-let _ = email_client.data();
-let _ = email_client.message("Test email");
-let _ = email_client.quit();
+let _ = email_client.smtp_command(EhloCommand::new(ClientId::new("my_hostname".to_string())));
+let _ = email_client.smtp_command(
+ MailCommand::new(Some(EmailAddress::new("user@example.com".to_string())), vec![])
+ );
+let _ = email_client.smtp_command(
+ RcptCommand::new(EmailAddress::new("user@example.org".to_string()), vec![])
+ );
+let _ = email_client.smtp_command(DataCommand);
+let _ = email_client.message(Box::new("Test email".as_bytes()));
+let _ = email_client.smtp_command(QuitCommand);
```
diff --git a/website/content/sending-messages/stub.md b/website/content/sending-messages/stub.md
index 27954a9..93d7c29 100644
--- a/website/content/sending-messages/stub.md
+++ b/website/content/sending-messages/stub.md
@@ -11,22 +11,22 @@ testing purposes.
``` rust
use lettre::stub::StubEmailTransport;
-use lettre::{SimpleSendableEmail, EmailTransport};
+use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
let email = SimpleSendableEmail::new(
- "user@localhost",
- vec!["root@localhost"],
- "message_id",
- "Hello world"
+ EmailAddress::new("user@localhost".to_string()),
+ vec![EmailAddress::new("root@localhost".to_string())],
+ "message_id".to_string(),
+ "Hello world".to_string(),
);
-let mut sender = StubEmailTransport;
-let result = sender.send(email);
+let mut sender = StubEmailTransport::new_positive();
+let result = sender.send(&email);
assert!(result.is_ok());
```
-Will log the line:
+Will log (when using a logger like `env_logger`):
```text
b7c211bc-9811-45ce-8cd9-68eab575d695: from= to=
-```
\ No newline at end of file
+```