Merge pull request #219 from amousset/fix-doc

fix(all): Fix documentation issues
This commit is contained in:
Alexis Mousset
2018-01-15 19:59:25 +01:00
committed by GitHub
28 changed files with 477 additions and 510 deletions

View File

@@ -17,6 +17,11 @@ Lettre provides the following features:
* Secure delivery with SMTP using encryption and authentication
* Easy email builders
## Example
See https://github.com/lettre/lettre/blob/master/lettre_email/examples/smtp.rs
for a simple example of how to build and send an email.
## Documentation
Released versions:

View File

@@ -9,14 +9,14 @@
<title>404 Page not found</title>
<link href="/lettre/css/nucleus.css?1508105428" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1508105428" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/horsey.css?1508105428" rel="stylesheet">
<link href="/lettre/css/theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1516041983" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1516041983" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/horsey.css?1516041983" rel="stylesheet">
<link href="/lettre/css/theme.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1516041983" rel="stylesheet">
<style type="text/css">
:root #header + #content > #left > #rlblock_left {

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="generator" content="Hugo 0.29" />
<meta name="generator" content="Hugo 0.32.4" />
<meta name="description" content="Documentation for the Lettre mailer in Rust">
<meta name="author" content="Alexis Mousset">
@@ -12,17 +12,17 @@
<title>Creating messages :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1508105428" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1508105428" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1508105428" rel="stylesheet">
<link href="/lettre/css/theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1516041983" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1516041983" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1516041983" rel="stylesheet">
<link href="/lettre/css/theme.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1516041983" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1508105428"></script>
<script src="/lettre/js/jquery-2.x.min.js?1516041983"></script>
<style type="text/css">
:root #header + #content > #left > #rlblock_left{
@@ -49,14 +49,14 @@
<span data-search-clear=""><i class="fa fa-close"></i></span>
</div>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1516041983"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1516041983"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/search.js?1516041983"></script>
</div>
@@ -362,6 +362,8 @@
<h3 id="creating-messages">Creating messages</h3>
<p>The documentation for the <code>lettre_email</code> is available on <a href="https://docs.rs/lettre_email/0.7.0/lettre_email/">https://docs.rs/lettre_email/0.7.0/lettre_email/</a> for now.</p>
<footer class=" footline" >
@@ -561,20 +563,20 @@
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
<script src="/lettre/js/clipboard.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1508105428"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1508105428"></script>
<script src="/lettre/js/featherlight.min.js?1508105428"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1508105428"></script>
<script src="/lettre/js/highlight.pack.js?1508105428"></script>
<script src="/lettre/js/clipboard.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1516041983"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1516041983"></script>
<script src="/lettre/js/featherlight.min.js?1516041983"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1516041983"></script>
<script src="/lettre/js/highlight.pack.js?1516041983"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1508105428"></script>
<script src="/lettre/js/learn.js?1508105428"></script>
<script src="/lettre/js/hugo-learn.js?1508105428"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1516041983"></script>
<script src="/lettre/js/learn.js?1516041983"></script>
<script src="/lettre/js/hugo-learn.js?1516041983"></script>
<link href="/lettre/mermaid/mermaid.css?1508105428" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1508105428"></script>
<link href="/lettre/mermaid/mermaid.css?1516041983" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1516041983"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="generator" content="Hugo 0.29" />
<meta name="generator" content="Hugo 0.32.4" />
<meta name="description" content="Documentation for the Lettre mailer in Rust">
<meta name="author" content="Alexis Mousset">
@@ -12,17 +12,17 @@
<title>Getting started :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1508105428" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1508105428" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1508105428" rel="stylesheet">
<link href="/lettre/css/theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1516041983" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1516041983" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1516041983" rel="stylesheet">
<link href="/lettre/css/theme.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1516041983" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1508105428"></script>
<script src="/lettre/js/jquery-2.x.min.js?1516041983"></script>
<style type="text/css">
:root #header + #content > #left > #rlblock_left{
@@ -49,14 +49,14 @@
<span data-search-clear=""><i class="fa fa-close"></i></span>
</div>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1516041983"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1516041983"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/search.js?1516041983"></script>
</div>
@@ -560,20 +560,20 @@
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
<script src="/lettre/js/clipboard.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1508105428"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1508105428"></script>
<script src="/lettre/js/featherlight.min.js?1508105428"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1508105428"></script>
<script src="/lettre/js/highlight.pack.js?1508105428"></script>
<script src="/lettre/js/clipboard.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1516041983"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1516041983"></script>
<script src="/lettre/js/featherlight.min.js?1516041983"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1516041983"></script>
<script src="/lettre/js/highlight.pack.js?1516041983"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1508105428"></script>
<script src="/lettre/js/learn.js?1508105428"></script>
<script src="/lettre/js/hugo-learn.js?1508105428"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1516041983"></script>
<script src="/lettre/js/learn.js?1516041983"></script>
<script src="/lettre/js/hugo-learn.js?1516041983"></script>
<link href="/lettre/mermaid/mermaid.css?1508105428" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1508105428"></script>
<link href="/lettre/mermaid/mermaid.css?1516041983" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1516041983"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="generator" content="Hugo 0.29" />
<meta name="generator" content="Hugo 0.32.4" />
<meta name="description" content="Documentation for the Lettre mailer in Rust">
<meta name="author" content="Alexis Mousset">
@@ -12,17 +12,17 @@
<title>Introduction :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1508105428" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1508105428" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1508105428" rel="stylesheet">
<link href="/lettre/css/theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1516041983" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1516041983" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1516041983" rel="stylesheet">
<link href="/lettre/css/theme.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1516041983" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1508105428"></script>
<script src="/lettre/js/jquery-2.x.min.js?1516041983"></script>
<style type="text/css">
:root #header + #content > #left > #rlblock_left{
@@ -49,14 +49,14 @@
<span data-search-clear=""><i class="fa fa-close"></i></span>
</div>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1516041983"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1516041983"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/search.js?1516041983"></script>
</div>
@@ -566,20 +566,20 @@ Please use <a href="https://docs.rs/lettre/0.6.2/lettre/">https://docs.rs/lettre
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
<script src="/lettre/js/clipboard.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1508105428"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1508105428"></script>
<script src="/lettre/js/featherlight.min.js?1508105428"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1508105428"></script>
<script src="/lettre/js/highlight.pack.js?1508105428"></script>
<script src="/lettre/js/clipboard.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1516041983"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1516041983"></script>
<script src="/lettre/js/featherlight.min.js?1516041983"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1516041983"></script>
<script src="/lettre/js/highlight.pack.js?1516041983"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1508105428"></script>
<script src="/lettre/js/learn.js?1508105428"></script>
<script src="/lettre/js/hugo-learn.js?1508105428"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1516041983"></script>
<script src="/lettre/js/learn.js?1516041983"></script>
<script src="/lettre/js/hugo-learn.js?1516041983"></script>
<link href="/lettre/mermaid/mermaid.css?1508105428" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1508105428"></script>
<link href="/lettre/mermaid/mermaid.css?1516041983" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1516041983"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -2,7 +2,7 @@
{
"uri": "/content/creating-messages/_index",
"title": "Creating messages",
"content": "\nCreating messages\n",
"content": "\nCreating messages\n\nThe documentation for the lettreemail is available on https://docs.rs/lettreemail/0.7.0/lettre_email/ for now.\n\n",
"tags": []
},
{
@@ -44,7 +44,7 @@
{
"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, 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",
"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.command(EhloCommand::new(ClientId::new(\"myhostname\".to_string())));\nlet _ = email_client.command(\n MailCommand::new(Some(EmailAddress::new(\"user@example.com\".to_string())), vec![])\n );\nlet _ = email_client.command(\n RcptCommand::new(EmailAddress::new(\"user@example.org\".to_string()), vec![])\n );\nlet _ = email_client.command(DataCommand);\nlet _ = emailclient.message(Box::new(\"Test email\".asbytes()));\nlet _ = email_client.command(QuitCommand);\n\n",
"tags": []
},
{

View File

@@ -52,7 +52,7 @@ The relay server can be the local email server, a specific host or a third-party
<guid>https://lettre.github.io/lettre/sending-messages/sendmail/</guid>
<description>The sendmail transport sends the email using the local sendmail command.
uselettre::sendmail::SendmailTransport;uselettre::{SimpleSendableEmail,EmailTransport,EmailAddress};letemail=SimpleSendableEmail::new(EmailAddress::new(&amp;#34;user@localhost&amp;#34;.to_string()),vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())],&amp;#34;message_id&amp;#34;.to_string(),&amp;#34;Hello world&amp;#34;.to_string(),);letmutsender=SendmailTransport::new();letresult=sender.send(&amp;amp;email);assert!(result.is_ok()); </description>
use lettre::sendmail::SendmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; let email = SimpleSendableEmail::new( EmailAddress::new(&amp;#34;user@localhost&amp;#34;.to_string()), vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ); let mut sender = SendmailTransport::new(); let result = sender.send(&amp;amp;email); assert!</description>
</item>
<item>
@@ -62,8 +62,7 @@ uselettre::sendmail::SendmailTransport;uselettre::{SimpleSendableEmail,EmailTran
<guid>https://lettre.github.io/lettre/sending-messages/file/</guid>
<description>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,EmailAddress};// Write to the local temp directory letmutsender=FileEmailTransport::new(temp_dir());letemail=SimpleSendableEmail::new(EmailAddress::new(&amp;#34;user@localhost&amp;#34;.to_string()),vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())],&amp;#34;message_id&amp;#34;.to_string(),&amp;#34;Hello world&amp;#34;.to_string(),);letresult=sender.send(&amp;amp;email);assert!(result.is_ok()); Example result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt:
b7c211bc-9811-45ce-8cd9-68eab575d695: from=&amp;lt;user@localhost&amp;gt; to=&amp;lt;root@localhost&amp;gt; To: &amp;lt;root@localhost&amp;gt; From: &amp;lt;user@localhost&amp;gt; Subject: Hello Date: Sat, 31 Oct 2015 13:42:19 +0100 Message-ID: &amp;lt;b7c211bc-9811-45ce-8cd9-68eab575d695.lettre@localhost&amp;gt; Hello World! </description>
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(&amp;#34;user@localhost&amp;#34;.to_string()), vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ); let result = sender.send(&amp;amp;email); assert!(result.is_ok()); Example result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.</description>
</item>
<item>
@@ -73,8 +72,8 @@ b7c211bc-9811-45ce-8cd9-68eab575d695: from=&amp;lt;user@localhost&amp;gt; to=&am
<guid>https://lettre.github.io/lettre/sending-messages/stub/</guid>
<description>The stub transport only logs message envelope and drops the content. It can be useful for testing purposes.
uselettre::stub::StubEmailTransport;uselettre::{SimpleSendableEmail,EmailTransport,EmailAddress};letemail=SimpleSendableEmail::new(EmailAddress::new(&amp;#34;user@localhost&amp;#34;.to_string()),vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())],&amp;#34;message_id&amp;#34;.to_string(),&amp;#34;Hello world&amp;#34;.to_string(),);letmutsender=StubEmailTransport::new_positive();letresult=sender.send(&amp;amp;email);assert!(result.is_ok()); Will log (when using a logger like env_logger):
b7c211bc-9811-45ce-8cd9-68eab575d695: from=&amp;lt;user@localhost&amp;gt; to=&amp;lt;root@localhost&amp;gt; </description>
use lettre::stub::StubEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; let email = SimpleSendableEmail::new( EmailAddress::new(&amp;#34;user@localhost&amp;#34;.to_string()), vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ); let mut sender = StubEmailTransport::new_positive(); let result = sender.send(&amp;amp;email); assert!(result.is_ok()); Will log (when using a logger like env_logger):
b7c211bc-9811-45ce-8cd9-68eab575d695: from=&amp;lt;user@localhost&amp;gt; to=&amp;lt;root@localhost&amp;gt;</description>
</item>
</channel>

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="generator" content="Hugo 0.29" />
<meta name="generator" content="Hugo 0.32.4" />
<meta name="description" content="Documentation for the Lettre mailer in Rust">
<meta name="author" content="Alexis Mousset">
@@ -12,17 +12,17 @@
<title>File transport :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1508105428" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1508105428" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1508105428" rel="stylesheet">
<link href="/lettre/css/theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1516041983" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1516041983" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1516041983" rel="stylesheet">
<link href="/lettre/css/theme.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1516041983" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1508105428"></script>
<script src="/lettre/js/jquery-2.x.min.js?1516041983"></script>
<style type="text/css">
:root #header + #content > #left > #rlblock_left{
@@ -49,14 +49,14 @@
<span data-search-clear=""><i class="fa fa-close"></i></span>
</div>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1516041983"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1516041983"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/search.js?1516041983"></script>
</div>
@@ -357,33 +357,31 @@
<p>The file transport writes the emails to the given directory. The name of the file will be
<code>message_id.txt</code>.
It can be useful for testing purposes, or if you want to keep track of sent messages.</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span><span style=""> </span><span style="">std</span><span style="">::</span><span style="">env</span><span style="">::</span><span style="">temp_dir</span><span style="">;</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">file</span><span style="">::</span><span style="">FileEmailTransport</span><span style="">;</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">{</span><span style="">SimpleSendableEmail</span><span style="">,</span><span style=""> </span><span style="">EmailTransport</span><span style="">,</span><span style=""> </span><span style="">EmailAddress</span><span style="">};</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#75715e">// Write to the local temp directory
</span><span style="color:#75715e"></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="color:#66d9ef">mut</span><span style=""> </span><span style="">sender</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">FileEmailTransport</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="">temp_dir</span><span style="">());</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">email</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">SimpleSendableEmail</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="">
</span><span style=""> </span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;user@localhost&#34;</span><span style="">.</span><span style="">to_string</span><span style="">()),</span><span style="">
</span><span style=""> </span><span style="">vec</span><span style="color:#f92672">!</span><span style="">[</span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;root@localhost&#34;</span><span style="">.</span><span style="">to_string</span><span style="">())],</span><span style="">
</span><span style=""> </span><span style="color:#e6db74">&#34;message_id&#34;</span><span style="">.</span><span style="">to_string</span><span style="">(),</span><span style="">
</span><span style=""> </span><span style="color:#e6db74">&#34;Hello world&#34;</span><span style="">.</span><span style="">to_string</span><span style="">(),</span><span style="">
</span><span style=""> </span><span style="">);</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">result</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">sender</span><span style="">.</span><span style="">send</span><span style="">(</span><span style="color:#f92672">&amp;</span><span style="">email</span><span style="">);</span><span style="">
</span><span style=""></span><span style="">assert</span><span style="color:#f92672">!</span><span style="">(</span><span style="">result</span><span style="">.</span><span style="">is_ok</span><span style="">());</span></code></pre>
</div>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span> std::env::temp_dir;
<span style="color:#66d9ef">use</span> lettre::file::FileEmailTransport;
<span style="color:#66d9ef">use</span> lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
<span style="color:#75715e">// Write to the local temp directory
</span><span style="color:#75715e"></span><span style="color:#66d9ef">let</span> <span style="color:#66d9ef">mut</span> sender <span style="color:#f92672">=</span> FileEmailTransport::new(temp_dir());
<span style="color:#66d9ef">let</span> email <span style="color:#f92672">=</span> SimpleSendableEmail::new(
EmailAddress::new(<span style="color:#e6db74">&#34;user@localhost&#34;</span>.to_string()),
vec<span style="color:#f92672">!</span>[EmailAddress::new(<span style="color:#e6db74">&#34;root@localhost&#34;</span>.to_string())],
<span style="color:#e6db74">&#34;message_id&#34;</span>.to_string(),
<span style="color:#e6db74">&#34;Hello world&#34;</span>.to_string(),
);
<span style="color:#66d9ef">let</span> result <span style="color:#f92672">=</span> sender.send(<span style="color:#f92672">&amp;</span>email);
assert<span style="color:#f92672">!</span>(result.is_ok());</code></pre></div>
<p>Example result in <code>/tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt</code>:</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-text" data-lang="text"><span style="">b7c211bc-9811-45ce-8cd9-68eab575d695: from=&lt;user@localhost&gt; to=&lt;root@localhost&gt;
</span><span style="">To: &lt;root@localhost&gt;
</span><span style="">From: &lt;user@localhost&gt;
</span><span style="">Subject: Hello
</span><span style="">Date: Sat, 31 Oct 2015 13:42:19 +0100
</span><span style="">Message-ID: &lt;b7c211bc-9811-45ce-8cd9-68eab575d695.lettre@localhost&gt;
</span><span style="">
</span><span style="">Hello World!</span></code></pre>
</div>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-text" data-lang="text">b7c211bc-9811-45ce-8cd9-68eab575d695: from=&lt;user@localhost&gt; to=&lt;root@localhost&gt;
To: &lt;root@localhost&gt;
From: &lt;user@localhost&gt;
Subject: Hello
Date: Sat, 31 Oct 2015 13:42:19 +0100
Message-ID: &lt;b7c211bc-9811-45ce-8cd9-68eab575d695.lettre@localhost&gt;
Hello World!</code></pre></div>
<footer class=" footline" >
@@ -588,20 +586,20 @@ It can be useful for testing purposes, or if you want to keep track of sent mess
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
<script src="/lettre/js/clipboard.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1508105428"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1508105428"></script>
<script src="/lettre/js/featherlight.min.js?1508105428"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1508105428"></script>
<script src="/lettre/js/highlight.pack.js?1508105428"></script>
<script src="/lettre/js/clipboard.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1516041983"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1516041983"></script>
<script src="/lettre/js/featherlight.min.js?1516041983"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1516041983"></script>
<script src="/lettre/js/highlight.pack.js?1516041983"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1508105428"></script>
<script src="/lettre/js/learn.js?1508105428"></script>
<script src="/lettre/js/hugo-learn.js?1508105428"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1516041983"></script>
<script src="/lettre/js/learn.js?1516041983"></script>
<script src="/lettre/js/hugo-learn.js?1516041983"></script>
<link href="/lettre/mermaid/mermaid.css?1508105428" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1508105428"></script>
<link href="/lettre/mermaid/mermaid.css?1516041983" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1516041983"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="generator" content="Hugo 0.29" />
<meta name="generator" content="Hugo 0.32.4" />
<meta name="description" content="Documentation for the Lettre mailer in Rust">
<meta name="author" content="Alexis Mousset">
@@ -12,17 +12,17 @@
<title>Sending messages :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1508105428" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1508105428" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1508105428" rel="stylesheet">
<link href="/lettre/css/theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1516041983" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1516041983" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1516041983" rel="stylesheet">
<link href="/lettre/css/theme.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1516041983" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1508105428"></script>
<script src="/lettre/js/jquery-2.x.min.js?1516041983"></script>
<style type="text/css">
:root #header + #content > #left > #rlblock_left{
@@ -49,14 +49,14 @@
<span data-search-clear=""><i class="fa fa-close"></i></span>
</div>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1516041983"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1516041983"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/search.js?1516041983"></script>
</div>
@@ -563,20 +563,20 @@
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
<script src="/lettre/js/clipboard.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1508105428"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1508105428"></script>
<script src="/lettre/js/featherlight.min.js?1508105428"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1508105428"></script>
<script src="/lettre/js/highlight.pack.js?1508105428"></script>
<script src="/lettre/js/clipboard.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1516041983"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1516041983"></script>
<script src="/lettre/js/featherlight.min.js?1516041983"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1516041983"></script>
<script src="/lettre/js/highlight.pack.js?1516041983"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1508105428"></script>
<script src="/lettre/js/learn.js?1508105428"></script>
<script src="/lettre/js/hugo-learn.js?1508105428"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1516041983"></script>
<script src="/lettre/js/learn.js?1516041983"></script>
<script src="/lettre/js/hugo-learn.js?1516041983"></script>
<link href="/lettre/mermaid/mermaid.css?1508105428" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1508105428"></script>
<link href="/lettre/mermaid/mermaid.css?1516041983" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1516041983"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -41,7 +41,7 @@ The relay server can be the local email server, a specific host or a third-party
<guid>https://lettre.github.io/lettre/sending-messages/sendmail/</guid>
<description>The sendmail transport sends the email using the local sendmail command.
uselettre::sendmail::SendmailTransport;uselettre::{SimpleSendableEmail,EmailTransport,EmailAddress};letemail=SimpleSendableEmail::new(EmailAddress::new(&amp;#34;user@localhost&amp;#34;.to_string()),vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())],&amp;#34;message_id&amp;#34;.to_string(),&amp;#34;Hello world&amp;#34;.to_string(),);letmutsender=SendmailTransport::new();letresult=sender.send(&amp;amp;email);assert!(result.is_ok()); </description>
use lettre::sendmail::SendmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; let email = SimpleSendableEmail::new( EmailAddress::new(&amp;#34;user@localhost&amp;#34;.to_string()), vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ); let mut sender = SendmailTransport::new(); let result = sender.send(&amp;amp;email); assert!</description>
</item>
<item>
@@ -51,8 +51,7 @@ uselettre::sendmail::SendmailTransport;uselettre::{SimpleSendableEmail,EmailTran
<guid>https://lettre.github.io/lettre/sending-messages/file/</guid>
<description>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,EmailAddress};// Write to the local temp directory letmutsender=FileEmailTransport::new(temp_dir());letemail=SimpleSendableEmail::new(EmailAddress::new(&amp;#34;user@localhost&amp;#34;.to_string()),vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())],&amp;#34;message_id&amp;#34;.to_string(),&amp;#34;Hello world&amp;#34;.to_string(),);letresult=sender.send(&amp;amp;email);assert!(result.is_ok()); Example result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt:
b7c211bc-9811-45ce-8cd9-68eab575d695: from=&amp;lt;user@localhost&amp;gt; to=&amp;lt;root@localhost&amp;gt; To: &amp;lt;root@localhost&amp;gt; From: &amp;lt;user@localhost&amp;gt; Subject: Hello Date: Sat, 31 Oct 2015 13:42:19 +0100 Message-ID: &amp;lt;b7c211bc-9811-45ce-8cd9-68eab575d695.lettre@localhost&amp;gt; Hello World! </description>
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(&amp;#34;user@localhost&amp;#34;.to_string()), vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ); let result = sender.send(&amp;amp;email); assert!(result.is_ok()); Example result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.</description>
</item>
<item>
@@ -62,8 +61,8 @@ b7c211bc-9811-45ce-8cd9-68eab575d695: from=&amp;lt;user@localhost&amp;gt; to=&am
<guid>https://lettre.github.io/lettre/sending-messages/stub/</guid>
<description>The stub transport only logs message envelope and drops the content. It can be useful for testing purposes.
uselettre::stub::StubEmailTransport;uselettre::{SimpleSendableEmail,EmailTransport,EmailAddress};letemail=SimpleSendableEmail::new(EmailAddress::new(&amp;#34;user@localhost&amp;#34;.to_string()),vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())],&amp;#34;message_id&amp;#34;.to_string(),&amp;#34;Hello world&amp;#34;.to_string(),);letmutsender=StubEmailTransport::new_positive();letresult=sender.send(&amp;amp;email);assert!(result.is_ok()); Will log (when using a logger like env_logger):
b7c211bc-9811-45ce-8cd9-68eab575d695: from=&amp;lt;user@localhost&amp;gt; to=&amp;lt;root@localhost&amp;gt; </description>
use lettre::stub::StubEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; let email = SimpleSendableEmail::new( EmailAddress::new(&amp;#34;user@localhost&amp;#34;.to_string()), vec![EmailAddress::new(&amp;#34;root@localhost&amp;#34;.to_string())], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ); let mut sender = StubEmailTransport::new_positive(); let result = sender.send(&amp;amp;email); assert!(result.is_ok()); Will log (when using a logger like env_logger):
b7c211bc-9811-45ce-8cd9-68eab575d695: from=&amp;lt;user@localhost&amp;gt; to=&amp;lt;root@localhost&amp;gt;</description>
</item>
</channel>

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="generator" content="Hugo 0.29" />
<meta name="generator" content="Hugo 0.32.4" />
<meta name="description" content="Documentation for the Lettre mailer in Rust">
<meta name="author" content="Alexis Mousset">
@@ -12,17 +12,17 @@
<title>Introduction :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1508105428" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1508105428" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1508105428" rel="stylesheet">
<link href="/lettre/css/theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1516041983" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1516041983" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1516041983" rel="stylesheet">
<link href="/lettre/css/theme.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1516041983" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1508105428"></script>
<script src="/lettre/js/jquery-2.x.min.js?1516041983"></script>
<style type="text/css">
:root #header + #content > #left > #rlblock_left{
@@ -49,14 +49,14 @@
<span data-search-clear=""><i class="fa fa-close"></i></span>
</div>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1516041983"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1516041983"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/search.js?1516041983"></script>
</div>
@@ -571,20 +571,20 @@ logs.</li>
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
<script src="/lettre/js/clipboard.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1508105428"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1508105428"></script>
<script src="/lettre/js/featherlight.min.js?1508105428"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1508105428"></script>
<script src="/lettre/js/highlight.pack.js?1508105428"></script>
<script src="/lettre/js/clipboard.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1516041983"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1516041983"></script>
<script src="/lettre/js/featherlight.min.js?1516041983"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1516041983"></script>
<script src="/lettre/js/highlight.pack.js?1516041983"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1508105428"></script>
<script src="/lettre/js/learn.js?1508105428"></script>
<script src="/lettre/js/hugo-learn.js?1508105428"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1516041983"></script>
<script src="/lettre/js/learn.js?1516041983"></script>
<script src="/lettre/js/hugo-learn.js?1516041983"></script>
<link href="/lettre/mermaid/mermaid.css?1508105428" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1508105428"></script>
<link href="/lettre/mermaid/mermaid.css?1516041983" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1516041983"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="generator" content="Hugo 0.29" />
<meta name="generator" content="Hugo 0.32.4" />
<meta name="description" content="Documentation for the Lettre mailer in Rust">
<meta name="author" content="Alexis Mousset">
@@ -12,17 +12,17 @@
<title>Sendmail transport :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1508105428" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1508105428" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1508105428" rel="stylesheet">
<link href="/lettre/css/theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1516041983" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1516041983" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1516041983" rel="stylesheet">
<link href="/lettre/css/theme.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1516041983" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1508105428"></script>
<script src="/lettre/js/jquery-2.x.min.js?1516041983"></script>
<style type="text/css">
:root #header + #content > #left > #rlblock_left{
@@ -49,14 +49,14 @@
<span data-search-clear=""><i class="fa fa-close"></i></span>
</div>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1516041983"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1516041983"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/search.js?1516041983"></script>
</div>
@@ -355,20 +355,19 @@
<p>The sendmail transport sends the email using the local sendmail command.</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">sendmail</span><span style="">::</span><span style="">SendmailTransport</span><span style="">;</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">{</span><span style="">SimpleSendableEmail</span><span style="">,</span><span style=""> </span><span style="">EmailTransport</span><span style="">,</span><span style=""> </span><span style="">EmailAddress</span><span style="">};</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">email</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">SimpleSendableEmail</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="">
</span><span style=""> </span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;user@localhost&#34;</span><span style="">.</span><span style="">to_string</span><span style="">()),</span><span style="">
</span><span style=""> </span><span style="">vec</span><span style="color:#f92672">!</span><span style="">[</span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;root@localhost&#34;</span><span style="">.</span><span style="">to_string</span><span style="">())],</span><span style="">
</span><span style=""> </span><span style="color:#e6db74">&#34;message_id&#34;</span><span style="">.</span><span style="">to_string</span><span style="">(),</span><span style="">
</span><span style=""> </span><span style="color:#e6db74">&#34;Hello world&#34;</span><span style="">.</span><span style="">to_string</span><span style="">(),</span><span style="">
</span><span style=""> </span><span style="">);</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="color:#66d9ef">mut</span><span style=""> </span><span style="">sender</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">SendmailTransport</span><span style="">::</span><span style="">new</span><span style="">();</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">result</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">sender</span><span style="">.</span><span style="">send</span><span style="">(</span><span style="color:#f92672">&amp;</span><span style="">email</span><span style="">);</span><span style="">
</span><span style=""></span><span style="">assert</span><span style="color:#f92672">!</span><span style="">(</span><span style="">result</span><span style="">.</span><span style="">is_ok</span><span style="">());</span></code></pre>
</div>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span> lettre::sendmail::SendmailTransport;
<span style="color:#66d9ef">use</span> lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
<span style="color:#66d9ef">let</span> email <span style="color:#f92672">=</span> SimpleSendableEmail::new(
EmailAddress::new(<span style="color:#e6db74">&#34;user@localhost&#34;</span>.to_string()),
vec<span style="color:#f92672">!</span>[EmailAddress::new(<span style="color:#e6db74">&#34;root@localhost&#34;</span>.to_string())],
<span style="color:#e6db74">&#34;message_id&#34;</span>.to_string(),
<span style="color:#e6db74">&#34;Hello world&#34;</span>.to_string(),
);
<span style="color:#66d9ef">let</span> <span style="color:#66d9ef">mut</span> sender <span style="color:#f92672">=</span> SendmailTransport::new();
<span style="color:#66d9ef">let</span> result <span style="color:#f92672">=</span> sender.send(<span style="color:#f92672">&amp;</span>email);
assert<span style="color:#f92672">!</span>(result.is_ok());</code></pre></div>
<footer class=" footline" >
@@ -573,20 +572,20 @@
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
<script src="/lettre/js/clipboard.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1508105428"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1508105428"></script>
<script src="/lettre/js/featherlight.min.js?1508105428"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1508105428"></script>
<script src="/lettre/js/highlight.pack.js?1508105428"></script>
<script src="/lettre/js/clipboard.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1516041983"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1516041983"></script>
<script src="/lettre/js/featherlight.min.js?1516041983"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1516041983"></script>
<script src="/lettre/js/highlight.pack.js?1516041983"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1508105428"></script>
<script src="/lettre/js/learn.js?1508105428"></script>
<script src="/lettre/js/hugo-learn.js?1508105428"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1516041983"></script>
<script src="/lettre/js/learn.js?1516041983"></script>
<script src="/lettre/js/hugo-learn.js?1516041983"></script>
<link href="/lettre/mermaid/mermaid.css?1508105428" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1508105428"></script>
<link href="/lettre/mermaid/mermaid.css?1516041983" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1516041983"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="generator" content="Hugo 0.29" />
<meta name="generator" content="Hugo 0.32.4" />
<meta name="description" content="Documentation for the Lettre mailer in Rust">
<meta name="author" content="Alexis Mousset">
@@ -12,17 +12,17 @@
<title>SMTP transport :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1508105428" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1508105428" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1508105428" rel="stylesheet">
<link href="/lettre/css/theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1516041983" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1516041983" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1516041983" rel="stylesheet">
<link href="/lettre/css/theme.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1516041983" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1508105428"></script>
<script src="/lettre/js/jquery-2.x.min.js?1516041983"></script>
<style type="text/css">
:root #header + #content > #left > #rlblock_left{
@@ -49,14 +49,14 @@
<span data-search-clear=""><i class="fa fa-close"></i></span>
</div>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1516041983"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1516041983"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/search.js?1516041983"></script>
</div>
@@ -389,85 +389,82 @@ emails directly to the destination.</p>
<h4 id="simple-example">Simple example</h4>
<p>This is the most basic example of usage:</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">{</span><span style="">SimpleSendableEmail</span><span style="">,</span><span style=""> </span><span style="">EmailTransport</span><span style="">,</span><span style=""> </span><span style="">EmailAddress</span><span style="">,</span><span style=""> </span><span style="">SmtpTransport</span><span style="">};</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">email</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">SimpleSendableEmail</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="">
</span><span style=""> </span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;user@localhost&#34;</span><span style="">.</span><span style="">to_string</span><span style="">()),</span><span style="">
</span><span style=""> </span><span style="">vec</span><span style="color:#f92672">!</span><span style="">[</span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;root@localhost&#34;</span><span style="">.</span><span style="">to_string</span><span style="">())],</span><span style="">
</span><span style=""> </span><span style="color:#e6db74">&#34;message_id&#34;</span><span style="">.</span><span style="">to_string</span><span style="">(),</span><span style="">
</span><span style=""> </span><span style="color:#e6db74">&#34;Hello world&#34;</span><span style="">.</span><span style="">to_string</span><span style="">(),</span><span style="">
</span><span style=""> </span><span style="">);</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#75715e">// Open a local connection on port 25
</span><span style="color:#75715e"></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="color:#66d9ef">mut</span><span style=""> </span><span style="">mailer</span><span style=""> </span><span style="color:#f92672">=</span><span style="">
</span><span style=""></span><span style="">SmtpTransport</span><span style="">::</span><span style="">builder_unencrypted_localhost</span><span style="">().</span><span style="">unwrap</span><span style="">().</span><span style="">build</span><span style="">();</span><span style="">
</span><span style=""></span><span style="color:#75715e">// Send the email
</span><span style="color:#75715e"></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">result</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">mailer</span><span style="">.</span><span style="">send</span><span style="">(</span><span style="color:#f92672">&amp;</span><span style="">email</span><span style="">);</span><span style="">
</span><span style="">
</span><span style=""></span><span style="">assert</span><span style="color:#f92672">!</span><span style="">(</span><span style="">result</span><span style="">.</span><span style="">is_ok</span><span style="">());</span></code></pre>
</div>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span> lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};
<span style="color:#66d9ef">let</span> email <span style="color:#f92672">=</span> SimpleSendableEmail::new(
EmailAddress::new(<span style="color:#e6db74">&#34;user@localhost&#34;</span>.to_string()),
vec<span style="color:#f92672">!</span>[EmailAddress::new(<span style="color:#e6db74">&#34;root@localhost&#34;</span>.to_string())],
<span style="color:#e6db74">&#34;message_id&#34;</span>.to_string(),
<span style="color:#e6db74">&#34;Hello world&#34;</span>.to_string(),
);
<span style="color:#75715e">// Open a local connection on port 25
</span><span style="color:#75715e"></span><span style="color:#66d9ef">let</span> <span style="color:#66d9ef">mut</span> mailer <span style="color:#f92672">=</span>
SmtpTransport::builder_unencrypted_localhost().unwrap().build();
<span style="color:#75715e">// Send the email
</span><span style="color:#75715e"></span><span style="color:#66d9ef">let</span> result <span style="color:#f92672">=</span> mailer.send(<span style="color:#f92672">&amp;</span>email);
assert<span style="color:#f92672">!</span>(result.is_ok());</code></pre></div>
<h4 id="complete-example">Complete example</h4>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">smtp</span><span style="">::</span><span style="">authentication</span><span style="">::</span><span style="">{</span><span style="">Credentials</span><span style="">,</span><span style=""> </span><span style="">Mechanism</span><span style="">};</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">smtp</span><span style="">::</span><span style="">SUBMISSION_PORT</span><span style="">;</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">{</span><span style="">SimpleSendableEmail</span><span style="">,</span><span style=""> </span><span style="">EmailTransport</span><span style="">,</span><span style=""> </span><span style="">EmailAddress</span><span style="">,</span><span style=""> </span><span style="">SmtpTransport</span><span style="">};</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">smtp</span><span style="">::</span><span style="">extension</span><span style="">::</span><span style="">ClientId</span><span style="">;</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">smtp</span><span style="">::</span><span style="">ConnectionReuseParameters</span><span style="">;</span><span style="">
</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">email</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">SimpleSendableEmail</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="">
</span><span style=""> </span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;user@localhost&#34;</span><span style="">.</span><span style="">to_string</span><span style="">()),</span><span style="">
</span><span style=""> </span><span style="">vec</span><span style="color:#f92672">!</span><span style="">[</span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;root@localhost&#34;</span><span style="">.</span><span style="">to_string</span><span style="">())],</span><span style="">
</span><span style=""> </span><span style="color:#e6db74">&#34;message_id&#34;</span><span style="">.</span><span style="">to_string</span><span style="">(),</span><span style="">
</span><span style=""> </span><span style="color:#e6db74">&#34;Hello world&#34;</span><span style="">.</span><span style="">to_string</span><span style="">(),</span><span style="">
</span><span style=""> </span><span style="">);</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#75715e">// Connect to a remote server on a custom port
</span><span style="color:#75715e"></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="color:#66d9ef">mut</span><span style=""> </span><span style="">mailer</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">SmtpTransport</span><span style="">::</span><span style="">simple_builder</span><span style="">(</span><span style="color:#e6db74">&#34;server.tld&#34;</span><span style="">.</span><span style="">to_string</span><span style="">()).</span><span style="">unwrap</span><span style="">()</span><span style="">
</span><span style=""> </span><span style="color:#75715e">// Set the name sent during EHLO/HELO, default is `localhost`
</span><span style="color:#75715e"></span><span style=""> </span><span style="">.</span><span style="">hello_name</span><span style="">(</span><span style="">ClientId</span><span style="">::</span><span style="">Domain</span><span style="">(</span><span style="color:#e6db74">&#34;my.hostname.tld&#34;</span><span style="">.</span><span style="">to_string</span><span style="">()))</span><span style="">
</span><span style=""> </span><span style="color:#75715e">// Add credentials for authentication
</span><span style="color:#75715e"></span><span style=""> </span><span style="">.</span><span style="">credentials</span><span style="">(</span><span style="">Credentials</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;username&#34;</span><span style="">.</span><span style="">to_string</span><span style="">(),</span><span style=""> </span><span style="color:#e6db74">&#34;password&#34;</span><span style="">.</span><span style="">to_string</span><span style="">()))</span><span style="">
</span><span style=""> </span><span style="color:#75715e">// Enable SMTPUTF8 if the server supports it
</span><span style="color:#75715e"></span><span style=""> </span><span style="">.</span><span style="">smtp_utf8</span><span style="">(</span><span style="color:#66d9ef">true</span><span style="">)</span><span style="">
</span><span style=""> </span><span style="color:#75715e">// Configure expected authentication mechanism
</span><span style="color:#75715e"></span><span style=""> </span><span style="">.</span><span style="">authentication_mechanism</span><span style="">(</span><span style="">Mechanism</span><span style="">::</span><span style="">Plain</span><span style="">)</span><span style="">
</span><span style=""> </span><span style="color:#75715e">// Enable connection reuse
</span><span style="color:#75715e"></span><span style=""> </span><span style="">.</span><span style="">connection_reuse</span><span style="">(</span><span style="">ConnectionReuseParameters</span><span style="">::</span><span style="">ReuseUnlimited</span><span style="">).</span><span style="">build</span><span style="">();</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">result_1</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">mailer</span><span style="">.</span><span style="">send</span><span style="">(</span><span style="color:#f92672">&amp;</span><span style="">email</span><span style="">);</span><span style="">
</span><span style=""></span><span style="">assert</span><span style="color:#f92672">!</span><span style="">(</span><span style="">result_1</span><span style="">.</span><span style="">is_ok</span><span style="">());</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#75715e">// The second email will use the same connection
</span><span style="color:#75715e"></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">result_2</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">mailer</span><span style="">.</span><span style="">send</span><span style="">(</span><span style="color:#f92672">&amp;</span><span style="">email</span><span style="">);</span><span style="">
</span><span style=""></span><span style="">assert</span><span style="color:#f92672">!</span><span style="">(</span><span style="">result_2</span><span style="">.</span><span style="">is_ok</span><span style="">());</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#75715e">// Explicitly close the SMTP transaction as we enabled connection reuse
</span><span style="color:#75715e"></span><span style="">mailer</span><span style="">.</span><span style="">close</span><span style="">();</span></code></pre>
</div>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span> lettre::smtp::authentication::{Credentials, Mechanism};
<span style="color:#66d9ef">use</span> lettre::smtp::SUBMISSION_PORT;
<span style="color:#66d9ef">use</span> lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};
<span style="color:#66d9ef">use</span> lettre::smtp::extension::ClientId;
<span style="color:#66d9ef">use</span> lettre::smtp::ConnectionReuseParameters;
<span style="color:#66d9ef">let</span> email <span style="color:#f92672">=</span> SimpleSendableEmail::new(
EmailAddress::new(<span style="color:#e6db74">&#34;user@localhost&#34;</span>.to_string()),
vec<span style="color:#f92672">!</span>[EmailAddress::new(<span style="color:#e6db74">&#34;root@localhost&#34;</span>.to_string())],
<span style="color:#e6db74">&#34;message_id&#34;</span>.to_string(),
<span style="color:#e6db74">&#34;Hello world&#34;</span>.to_string(),
);
<span style="color:#75715e">// Connect to a remote server on a custom port
</span><span style="color:#75715e"></span><span style="color:#66d9ef">let</span> <span style="color:#66d9ef">mut</span> mailer <span style="color:#f92672">=</span> SmtpTransport::simple_builder(<span style="color:#e6db74">&#34;server.tld&#34;</span>.to_string()).unwrap()
<span style="color:#75715e">// Set the name sent during EHLO/HELO, default is `localhost`
</span><span style="color:#75715e"></span> .hello_name(ClientId::Domain(<span style="color:#e6db74">&#34;my.hostname.tld&#34;</span>.to_string()))
<span style="color:#75715e">// Add credentials for authentication
</span><span style="color:#75715e"></span> .credentials(Credentials::new(<span style="color:#e6db74">&#34;username&#34;</span>.to_string(), <span style="color:#e6db74">&#34;password&#34;</span>.to_string()))
<span style="color:#75715e">// Enable SMTPUTF8 if the server supports it
</span><span style="color:#75715e"></span> .smtp_utf8(<span style="color:#66d9ef">true</span>)
<span style="color:#75715e">// Configure expected authentication mechanism
</span><span style="color:#75715e"></span> .authentication_mechanism(Mechanism::Plain)
<span style="color:#75715e">// Enable connection reuse
</span><span style="color:#75715e"></span> .connection_reuse(ConnectionReuseParameters::ReuseUnlimited).build();
<span style="color:#66d9ef">let</span> result_1 <span style="color:#f92672">=</span> mailer.send(<span style="color:#f92672">&amp;</span>email);
assert<span style="color:#f92672">!</span>(result_1.is_ok());
<span style="color:#75715e">// The second email will use the same connection
</span><span style="color:#75715e"></span><span style="color:#66d9ef">let</span> result_2 <span style="color:#f92672">=</span> mailer.send(<span style="color:#f92672">&amp;</span>email);
assert<span style="color:#f92672">!</span>(result_2.is_ok());
<span style="color:#75715e">// Explicitly close the SMTP transaction as we enabled connection reuse
</span><span style="color:#75715e"></span>mailer.close();</code></pre></div>
<h4 id="lower-level">Lower level</h4>
<p>You can also send commands, here is a simple email transaction without
error handling:</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">EmailAddress</span><span style="">;</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">smtp</span><span style="">::</span><span style="">SMTP_PORT</span><span style="">;</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">smtp</span><span style="">::</span><span style="">client</span><span style="">::</span><span style="">Client</span><span style="">;</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">smtp</span><span style="">::</span><span style="">client</span><span style="">::</span><span style="">net</span><span style="">::</span><span style="">NetworkStream</span><span style="">;</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">smtp</span><span style="">::</span><span style="">extension</span><span style="">::</span><span style="">ClientId</span><span style="">;</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">smtp</span><span style="">::</span><span style="">commands</span><span style="">::</span><span style="color:#f92672">*</span><span style="">;</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="color:#66d9ef">mut</span><span style=""> </span><span style="">email_client</span><span style="">: </span><span style="color:#a6e22e">Client</span><span style="color:#f92672">&lt;</span><span style="">NetworkStream</span><span style="color:#f92672">&gt;</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">Client</span><span style="">::</span><span style="">new</span><span style="">();</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">_</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">email_client</span><span style="">.</span><span style="">connect</span><span style="">(</span><span style="color:#f92672">&amp;</span><span style="">(</span><span style="color:#e6db74">&#34;localhost&#34;</span><span style="">,</span><span style=""> </span><span style="">SMTP_PORT</span><span style="">),</span><span style=""> </span><span style="">None</span><span style="">);</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">_</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">email_client</span><span style="">.</span><span style="">smtp_command</span><span style="">(</span><span style="">EhloCommand</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="">ClientId</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;my_hostname&#34;</span><span style="">.</span><span style="">to_string</span><span style="">())));</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">_</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">email_client</span><span style="">.</span><span style="">smtp_command</span><span style="">(</span><span style="">
</span><span style=""> </span><span style="">MailCommand</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="">Some</span><span style="">(</span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;user@example.com&#34;</span><span style="">.</span><span style="">to_string</span><span style="">())),</span><span style=""> </span><span style="">vec</span><span style="color:#f92672">!</span><span style="">[])</span><span style="">
</span><span style=""> </span><span style="">);</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">_</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">email_client</span><span style="">.</span><span style="">smtp_command</span><span style="">(</span><span style="">
</span><span style=""> </span><span style="">RcptCommand</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;user@example.org&#34;</span><span style="">.</span><span style="">to_string</span><span style="">()),</span><span style=""> </span><span style="">vec</span><span style="color:#f92672">!</span><span style="">[])</span><span style="">
</span><span style=""> </span><span style="">);</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">_</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">email_client</span><span style="">.</span><span style="">smtp_command</span><span style="">(</span><span style="">DataCommand</span><span style="">);</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">_</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">email_client</span><span style="">.</span><span style="">message</span><span style="">(</span><span style="">Box</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;Test email&#34;</span><span style="">.</span><span style="">as_bytes</span><span style="">()));</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">_</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">email_client</span><span style="">.</span><span style="">smtp_command</span><span style="">(</span><span style="">QuitCommand</span><span style="">);</span></code></pre>
</div>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span> lettre::EmailAddress;
<span style="color:#66d9ef">use</span> lettre::smtp::SMTP_PORT;
<span style="color:#66d9ef">use</span> lettre::smtp::client::Client;
<span style="color:#66d9ef">use</span> lettre::smtp::client::net::NetworkStream;
<span style="color:#66d9ef">use</span> lettre::smtp::extension::ClientId;
<span style="color:#66d9ef">use</span> lettre::smtp::commands::<span style="color:#f92672">*</span>;
<span style="color:#66d9ef">let</span> <span style="color:#66d9ef">mut</span> email_client: <span style="color:#a6e22e">Client</span><span style="color:#f92672">&lt;</span>NetworkStream<span style="color:#f92672">&gt;</span> <span style="color:#f92672">=</span> Client::new();
<span style="color:#66d9ef">let</span> _ <span style="color:#f92672">=</span> email_client.connect(<span style="color:#f92672">&amp;</span>(<span style="color:#e6db74">&#34;localhost&#34;</span>, SMTP_PORT), None);
<span style="color:#66d9ef">let</span> _ <span style="color:#f92672">=</span> email_client.command(EhloCommand::new(ClientId::new(<span style="color:#e6db74">&#34;my_hostname&#34;</span>.to_string())));
<span style="color:#66d9ef">let</span> _ <span style="color:#f92672">=</span> email_client.command(
MailCommand::new(Some(EmailAddress::new(<span style="color:#e6db74">&#34;user@example.com&#34;</span>.to_string())), vec<span style="color:#f92672">!</span>[])
);
<span style="color:#66d9ef">let</span> _ <span style="color:#f92672">=</span> email_client.command(
RcptCommand::new(EmailAddress::new(<span style="color:#e6db74">&#34;user@example.org&#34;</span>.to_string()), vec<span style="color:#f92672">!</span>[])
);
<span style="color:#66d9ef">let</span> _ <span style="color:#f92672">=</span> email_client.command(DataCommand);
<span style="color:#66d9ef">let</span> _ <span style="color:#f92672">=</span> email_client.message(Box::new(<span style="color:#e6db74">&#34;Test email&#34;</span>.as_bytes()));
<span style="color:#66d9ef">let</span> _ <span style="color:#f92672">=</span> email_client.command(QuitCommand);</code></pre></div>
<footer class=" footline" >
@@ -672,20 +669,20 @@ error handling:</p>
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
<script src="/lettre/js/clipboard.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1508105428"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1508105428"></script>
<script src="/lettre/js/featherlight.min.js?1508105428"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1508105428"></script>
<script src="/lettre/js/highlight.pack.js?1508105428"></script>
<script src="/lettre/js/clipboard.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1516041983"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1516041983"></script>
<script src="/lettre/js/featherlight.min.js?1516041983"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1516041983"></script>
<script src="/lettre/js/highlight.pack.js?1516041983"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1508105428"></script>
<script src="/lettre/js/learn.js?1508105428"></script>
<script src="/lettre/js/hugo-learn.js?1508105428"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1516041983"></script>
<script src="/lettre/js/learn.js?1516041983"></script>
<script src="/lettre/js/hugo-learn.js?1516041983"></script>
<link href="/lettre/mermaid/mermaid.css?1508105428" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1508105428"></script>
<link href="/lettre/mermaid/mermaid.css?1516041983" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1516041983"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="generator" content="Hugo 0.29" />
<meta name="generator" content="Hugo 0.32.4" />
<meta name="description" content="Documentation for the Lettre mailer in Rust">
<meta name="author" content="Alexis Mousset">
@@ -12,17 +12,17 @@
<title>Stub transport :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1508105428" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1508105428" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1508105428" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1508105428" rel="stylesheet">
<link href="/lettre/css/theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1508105428" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1516041983" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1516041983" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1516041983" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1516041983" rel="stylesheet">
<link href="/lettre/css/theme.css?1516041983" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1516041983" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1508105428"></script>
<script src="/lettre/js/jquery-2.x.min.js?1516041983"></script>
<style type="text/css">
:root #header + #content > #left > #rlblock_left{
@@ -49,14 +49,14 @@
<span data-search-clear=""><i class="fa fa-close"></i></span>
</div>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1516041983"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1516041983"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1508105428"></script>
<script type="text/javascript" src="/lettre/js/search.js?1516041983"></script>
</div>
@@ -356,23 +356,21 @@
<p>The stub transport only logs message envelope and drops the content. It can be useful for
testing purposes.</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">stub</span><span style="">::</span><span style="">StubEmailTransport</span><span style="">;</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">use</span><span style=""> </span><span style="">lettre</span><span style="">::</span><span style="">{</span><span style="">SimpleSendableEmail</span><span style="">,</span><span style=""> </span><span style="">EmailTransport</span><span style="">,</span><span style=""> </span><span style="">EmailAddress</span><span style="">};</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">email</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">SimpleSendableEmail</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="">
</span><span style=""> </span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;user@localhost&#34;</span><span style="">.</span><span style="">to_string</span><span style="">()),</span><span style="">
</span><span style=""> </span><span style="">vec</span><span style="color:#f92672">!</span><span style="">[</span><span style="">EmailAddress</span><span style="">::</span><span style="">new</span><span style="">(</span><span style="color:#e6db74">&#34;root@localhost&#34;</span><span style="">.</span><span style="">to_string</span><span style="">())],</span><span style="">
</span><span style=""> </span><span style="color:#e6db74">&#34;message_id&#34;</span><span style="">.</span><span style="">to_string</span><span style="">(),</span><span style="">
</span><span style=""> </span><span style="color:#e6db74">&#34;Hello world&#34;</span><span style="">.</span><span style="">to_string</span><span style="">(),</span><span style="">
</span><span style=""> </span><span style="">);</span><span style="">
</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="color:#66d9ef">mut</span><span style=""> </span><span style="">sender</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">StubEmailTransport</span><span style="">::</span><span style="">new_positive</span><span style="">();</span><span style="">
</span><span style=""></span><span style="color:#66d9ef">let</span><span style=""> </span><span style="">result</span><span style=""> </span><span style="color:#f92672">=</span><span style=""> </span><span style="">sender</span><span style="">.</span><span style="">send</span><span style="">(</span><span style="color:#f92672">&amp;</span><span style="">email</span><span style="">);</span><span style="">
</span><span style=""></span><span style="">assert</span><span style="color:#f92672">!</span><span style="">(</span><span style="">result</span><span style="">.</span><span style="">is_ok</span><span style="">());</span></code></pre>
</div>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span> lettre::stub::StubEmailTransport;
<span style="color:#66d9ef">use</span> lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
<span style="color:#66d9ef">let</span> email <span style="color:#f92672">=</span> SimpleSendableEmail::new(
EmailAddress::new(<span style="color:#e6db74">&#34;user@localhost&#34;</span>.to_string()),
vec<span style="color:#f92672">!</span>[EmailAddress::new(<span style="color:#e6db74">&#34;root@localhost&#34;</span>.to_string())],
<span style="color:#e6db74">&#34;message_id&#34;</span>.to_string(),
<span style="color:#e6db74">&#34;Hello world&#34;</span>.to_string(),
);
<span style="color:#66d9ef">let</span> <span style="color:#66d9ef">mut</span> sender <span style="color:#f92672">=</span> StubEmailTransport::new_positive();
<span style="color:#66d9ef">let</span> result <span style="color:#f92672">=</span> sender.send(<span style="color:#f92672">&amp;</span>email);
assert<span style="color:#f92672">!</span>(result.is_ok());</code></pre></div>
<p>Will log (when using a logger like <code>env_logger</code>):</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-text" data-lang="text"><span style="">b7c211bc-9811-45ce-8cd9-68eab575d695: from=&lt;user@localhost&gt; to=&lt;root@localhost&gt;</span></code></pre>
</div>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-text" data-lang="text">b7c211bc-9811-45ce-8cd9-68eab575d695: from=&lt;user@localhost&gt; to=&lt;root@localhost&gt;</code></pre></div>
<footer class=" footline" >
@@ -574,20 +572,20 @@ testing purposes.</p>
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
<script src="/lettre/js/clipboard.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1508105428"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1508105428"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1508105428"></script>
<script src="/lettre/js/featherlight.min.js?1508105428"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1508105428"></script>
<script src="/lettre/js/highlight.pack.js?1508105428"></script>
<script src="/lettre/js/clipboard.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1516041983"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1516041983"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1516041983"></script>
<script src="/lettre/js/featherlight.min.js?1516041983"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1516041983"></script>
<script src="/lettre/js/highlight.pack.js?1516041983"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1508105428"></script>
<script src="/lettre/js/learn.js?1508105428"></script>
<script src="/lettre/js/hugo-learn.js?1508105428"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1516041983"></script>
<script src="/lettre/js/learn.js?1516041983"></script>
<script src="/lettre/js/hugo-learn.js?1516041983"></script>
<link href="/lettre/mermaid/mermaid.css?1508105428" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1508105428"></script>
<link href="/lettre/mermaid/mermaid.css?1516041983" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1516041983"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -13,10 +13,10 @@ fn bench_simple_send(b: &mut test::Bencher) {
.build();
b.iter(|| {
let email =
SimpleSendableEmail::new(EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"id".to_string(),
"Hello world".to_string());
SimpleSendableEmail::new(EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"id".to_string(),
"Hello world".to_string());
let result = sender.send(&email);
assert!(result.is_ok());
});
@@ -30,10 +30,10 @@ fn bench_reuse_send(b: &mut test::Bencher) {
.build();
b.iter(|| {
let email =
SimpleSendableEmail::new(EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"id".to_string(),
"Hello world".to_string());
SimpleSendableEmail::new(EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"id".to_string(),
"Hello world".to_string());
let result = sender.send(&email);
assert!(result.is_ok());
});

View File

@@ -30,7 +30,6 @@ pub const DEFAULT_UNENCRYPTED_MECHANISMS: &[Mechanism] = &[Mechanism::CramMd5];
#[cfg(not(feature = "crammd5-auth"))]
pub const DEFAULT_UNENCRYPTED_MECHANISMS: &[Mechanism] = &[];
/// Convertable to user credentials
pub trait IntoCredentials {
/// Converts to a `Credentials` struct
@@ -111,18 +110,14 @@ impl Mechanism {
challenge: Option<&str>)
-> Result<String, Error> {
match *self {
Mechanism::Plain => {
match challenge {
Some(_) => Err(Error::Client("This mechanism does not expect a challenge")),
None => {
Ok(format!("{}{}{}{}",
Mechanism::Plain => match challenge {
Some(_) => Err(Error::Client("This mechanism does not expect a challenge")),
None => Ok(format!("{}{}{}{}",
NUL,
credentials.username,
NUL,
credentials.password))
}
}
}
credentials.password)),
},
Mechanism::Login => {
let decoded_challenge = match challenge {
Some(challenge) => challenge,

View File

@@ -14,7 +14,6 @@ use std::net::ToSocketAddrs;
use std::string::String;
use std::time::Duration;
pub mod net;
pub mod mock;

View File

@@ -44,9 +44,11 @@ impl NetworkStream {
match *self {
NetworkStream::Tcp(ref s) => s.peer_addr(),
NetworkStream::Tls(ref s) => s.get_ref().peer_addr(),
NetworkStream::Mock(_) => {
Ok(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 80)))
}
NetworkStream::Mock(_) => Ok(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127,
0,
0,
1),
80))),
}
}
@@ -106,12 +108,10 @@ impl Connector for NetworkStream {
let tcp_stream = TcpStream::connect(addr)?;
match tls_parameters {
Some(context) => {
context.connector
.connect(context.domain.as_ref(), tcp_stream)
.map(NetworkStream::Tls)
.map_err(|e| io::Error::new(ErrorKind::Other, e))
}
Some(context) => context.connector
.connect(context.domain.as_ref(), tcp_stream)
.map(NetworkStream::Tls)
.map_err(|e| io::Error::new(ErrorKind::Other, e)),
None => Ok(NetworkStream::Tcp(tcp_stream)),
}
}

View File

@@ -243,9 +243,9 @@ impl AuthCommand {
None
};
Ok(AuthCommand { mechanism: mechanism,
credentials: credentials,
challenge: challenge,
response: response, })
credentials: credentials,
challenge: challenge,
response: response, })
}
/// Creates an AUTH command from a response that needs to be a
@@ -266,12 +266,10 @@ impl AuthCommand {
debug!("auth encoded challenge: {}", encoded_challenge);
let decoded_challenge = match base64::decode(&encoded_challenge) {
Ok(challenge) => {
match String::from_utf8(challenge) {
Ok(value) => value,
Err(error) => return Err(Error::Utf8Parsing(error)),
}
}
Ok(challenge) => match String::from_utf8(challenge) {
Ok(value) => value,
Err(error) => return Err(Error::Utf8Parsing(error)),
},
Err(error) => return Err(Error::ChallengeParsing(error)),
};
@@ -280,9 +278,9 @@ impl AuthCommand {
let response = Some(mechanism.response(&credentials, Some(decoded_challenge.as_ref()))?);
Ok(AuthCommand { mechanism: mechanism,
credentials: credentials,
challenge: Some(decoded_challenge),
response: response, })
credentials: credentials,
challenge: Some(decoded_challenge),
response: response, })
}
}

View File

@@ -52,18 +52,14 @@ impl StdError for Error {
match *self {
// Try to display the first line of the server's response that usually
// contains a short humanly readable error message
Transient(ref err) => {
match err.first_line() {
Some(line) => line,
None => "undetailed transient error during SMTP transaction",
}
}
Permanent(ref err) => {
match err.first_line() {
Some(line) => line,
None => "undetailed permanent error during SMTP transaction",
}
}
Transient(ref err) => match err.first_line() {
Some(line) => line,
None => "undetailed transient error during SMTP transaction",
},
Permanent(ref err) => match err.first_line() {
Some(line) => line,
None => "undetailed permanent error during SMTP transaction",
},
ResponseParsing(err) => err,
ChallengeParsing(ref err) => err.description(),
Utf8Parsing(ref err) => err.description(),

View File

@@ -132,29 +132,27 @@ impl ServerInfo {
"STARTTLS" => {
features.insert(Extension::StartTls);
}
"AUTH" => {
for &mechanism in &splitted[1..] {
match mechanism {
"PLAIN" => {
features.insert(Extension::Authentication(Mechanism::Plain));
}
"LOGIN" => {
features.insert(Extension::Authentication(Mechanism::Login));
}
#[cfg(feature = "crammd5-auth")]
"CRAM-MD5" => {
features.insert(Extension::Authentication(Mechanism::CramMd5));
}
_ => (),
"AUTH" => for &mechanism in &splitted[1..] {
match mechanism {
"PLAIN" => {
features.insert(Extension::Authentication(Mechanism::Plain));
}
"LOGIN" => {
features.insert(Extension::Authentication(Mechanism::Login));
}
#[cfg(feature = "crammd5-auth")]
"CRAM-MD5" => {
features.insert(Extension::Authentication(Mechanism::CramMd5));
}
_ => (),
}
}
},
_ => (),
};
}
Ok(ServerInfo { name: name.to_string(),
features: features, })
features: features, })
}
/// Checks if the server supports an ESMTP feature
@@ -248,7 +246,7 @@ impl Display for RcptParameter {
#[cfg(test)]
mod test {
use super::{Extension, ServerInfo, ClientId};
use super::{ClientId, Extension, ServerInfo};
use smtp::authentication::Mechanism;
use smtp::response::{Category, Code, Detail, Response, Severity};
use std::collections::HashSet;

View File

@@ -215,16 +215,14 @@ impl SmtpTransportBuilder {
let mut addresses = addr.to_socket_addrs()?;
match addresses.next() {
Some(addr) => {
Ok(SmtpTransportBuilder { server_addr: addr,
security: security,
smtp_utf8: false,
credentials: None,
connection_reuse: ConnectionReuseParameters::NoReuse,
hello_name: ClientId::hostname(),
authentication_mechanism: None,
timeout: Some(Duration::new(60, 0)), })
}
Some(addr) => Ok(SmtpTransportBuilder { server_addr: addr,
security: security,
smtp_utf8: false,
credentials: None,
connection_reuse: ConnectionReuseParameters::NoReuse,
hello_name: ClientId::hostname(),
authentication_mechanism: None,
timeout: Some(Duration::new(60, 0)), }),
None => Err(Error::Resolution),
}
}
@@ -451,7 +449,8 @@ impl<'a, T: Read + 'a> EmailTransport<'a, T, SmtpResult> for SmtpTransport {
for mechanism in accepted_mechanisms {
if self.server_info.as_ref()
.unwrap()
.supports_auth_mechanism(mechanism) {
.supports_auth_mechanism(mechanism)
{
found = true;
try_smtp!(
self.client
@@ -473,13 +472,15 @@ impl<'a, T: Read + 'a> EmailTransport<'a, T, SmtpResult> for SmtpTransport {
if self.server_info.as_ref()
.unwrap()
.supports_feature(Extension::EightBitMime) {
.supports_feature(Extension::EightBitMime)
{
mail_options.push(MailParameter::Body(MailBodyParameter::EightBitMime));
}
if self.server_info.as_ref()
.unwrap()
.supports_feature(Extension::SmtpUtfEight) && self.client_info.smtp_utf8 {
.supports_feature(Extension::SmtpUtfEight) && self.client_info.smtp_utf8
{
mail_options.push(MailParameter::SmtpUtfEight);
}

View File

@@ -53,26 +53,16 @@ impl Display for Category {
/// The detail digit of a response code (third digit)
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub enum Detail {
#[allow(missing_docs)]
Zero = 0,
#[allow(missing_docs)]
One = 1,
#[allow(missing_docs)]
Two = 2,
#[allow(missing_docs)]
Three = 3,
#[allow(missing_docs)]
Four = 4,
#[allow(missing_docs)]
Five = 5,
#[allow(missing_docs)]
Six = 6,
#[allow(missing_docs)]
Seven = 7,
#[allow(missing_docs)]
Eight = 8,
#[allow(missing_docs)]
Nine = 9,
#[allow(missing_docs)] Zero = 0,
#[allow(missing_docs)] One = 1,
#[allow(missing_docs)] Two = 2,
#[allow(missing_docs)] Three = 3,
#[allow(missing_docs)] Four = 4,
#[allow(missing_docs)] Five = 5,
#[allow(missing_docs)] Six = 6,
#[allow(missing_docs)] Seven = 7,
#[allow(missing_docs)] Eight = 8,
#[allow(missing_docs)] Nine = 9,
}
impl Display for Detail {
@@ -167,11 +157,9 @@ impl Response {
named!(parse_code<Code>,
map!(tuple!(parse_severity, parse_category, parse_detail),
|(severity, category, detail)| {
Code { severity: severity,
category: category,
detail: detail, }
}));
|(severity, category, detail)| Code { severity: severity,
category: category,
detail: detail, }));
named!(
parse_severity<Severity>,
@@ -234,10 +222,10 @@ named!(parse_response<Response>,
}
Ok(Response { code: last_code,
message: lines.into_iter()
.map(|line| from_utf8(line).map(|s| s.to_string()))
.collect::<result::Result<Vec<_>, _>>()
.map_err(|_| ())?, })
message: lines.into_iter()
.map(|line| from_utf8(line).map(|s| s.to_string()))
.collect::<result::Result<Vec<_>, _>>()
.map_err(|_| ())?, })
}));
#[cfg(test)]

View File

@@ -27,7 +27,6 @@ impl<'a> Display for XText<'a> {
}
}
#[cfg(test)]
mod tests {
use super::XText;
@@ -37,7 +36,8 @@ mod tests {
for (input, expect) in vec![("bjorn", "bjorn"),
("bjørn", "bjørn"),
("Ø+= ❤️‰", "Ø+2B+3D+20❤"),
("+", "+2B")] {
("+", "+2B")]
{
assert_eq!(format!("{}", XText(input)), expect);
}
}

View File

@@ -170,7 +170,6 @@ impl IntoEmail for SimpleEmail {
}
}
/// Simple representation of an email, useful for some transports
#[derive(PartialEq, Eq, Clone, Debug, Default)]
pub struct SimpleEmail {
@@ -323,7 +322,6 @@ impl Default for PartBuilder {
}
}
/// Builds an `Email` structure
#[derive(PartialEq, Eq, Clone, Debug, Default)]
pub struct EmailBuilder {
@@ -628,17 +626,13 @@ impl EmailBuilder {
let actual_filename = match filename {
Some(name) => name,
None => {
match path.file_name() {
Some(name) => {
match name.to_str() {
Some(name) => name,
None => return Err(Error::CannotParseFilename),
}
}
None => match path.file_name() {
Some(name) => match name.to_str() {
Some(name) => name,
None => return Err(Error::CannotParseFilename),
}
}
},
None => return Err(Error::CannotParseFilename),
},
};
let content = PartBuilder::new().body(body)
@@ -778,14 +772,13 @@ impl EmailBuilder {
// add all receivers in to_header and cc_header
for receiver in self.to_header.iter()
.chain(self.cc_header.iter())
.chain(self.bcc_header.iter()) {
.chain(self.bcc_header.iter())
{
match *receiver {
Address::Mailbox(ref m) => e.add_to(m.address.clone()),
Address::Group(_, ref ms) => {
for m in ms.iter() {
e.add_to(m.address.clone());
}
}
Address::Group(_, ref ms) => for m in ms.iter() {
e.add_to(m.address.clone());
},
}
}
if e.to.is_empty() {
@@ -844,7 +837,8 @@ impl EmailBuilder {
let message_id = Uuid::new_v4();
if let Ok(header) = Header::new_with_value("Message-ID".to_string(),
format!("<{}.lettre@localhost>", message_id)) {
format!("<{}.lettre@localhost>", message_id))
{
self.message.add_header(header)
}
@@ -899,7 +893,6 @@ pub trait ExtractableEmail {
fn text(self) -> String;
}
#[cfg(test)]
mod test {

View File

@@ -4,4 +4,3 @@ reorder_imported_names = true
reorder_imports_in_group = true
struct_field_align_threshold = 20
indent_style = "Visual"
chain_indent = "Visual"

View File

@@ -1,3 +1,3 @@
#!/bin/sh
hugo
lunr-hugo -i "content/**/*.md" -o ../docs/json/search.json -l toml
lunr-hugo -i "content/**/*.md" -o ../docs/index.json -l toml

View File

@@ -7,3 +7,6 @@ weight = 2
+++
### Creating messages
The documentation for the `lettre_email` is available on https://docs.rs/lettre_email/0.7.0/lettre_email/ for now.