feat(all): Move Envelope from lettre_email to lettre

This commit is contained in:
Alexis Mousset
2018-03-31 16:11:27 +02:00
parent bef45c48f7
commit f3f963c6a5
34 changed files with 578 additions and 444 deletions

View File

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

View File

@@ -12,17 +12,17 @@
<title>Email creation :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1517057321" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1517057321" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1517057321" rel="stylesheet">
<link href="/lettre/css/theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1522506318" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1522506318" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1522506318" rel="stylesheet">
<link href="/lettre/css/theme.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1522506318" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1517057321"></script>
<script src="/lettre/js/jquery-2.x.min.js?1522506318"></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?1517057321"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1522506318"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1522506318"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/search.js?1522506318"></script>
</div>
@@ -669,20 +669,20 @@ as fallback for the HTML version.</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?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1517057321"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1517057321"></script>
<script src="/lettre/js/featherlight.min.js?1517057321"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1517057321"></script>
<script src="/lettre/js/highlight.pack.js?1517057321"></script>
<script src="/lettre/js/clipboard.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1522506318"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1522506318"></script>
<script src="/lettre/js/featherlight.min.js?1522506318"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1522506318"></script>
<script src="/lettre/js/highlight.pack.js?1522506318"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1517057321"></script>
<script src="/lettre/js/learn.js?1517057321"></script>
<script src="/lettre/js/hugo-learn.js?1517057321"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1522506318"></script>
<script src="/lettre/js/learn.js?1522506318"></script>
<script src="/lettre/js/hugo-learn.js?1522506318"></script>
<link href="/lettre/mermaid/mermaid.css?1517057321" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1517057321"></script>
<link href="/lettre/mermaid/mermaid.css?1522506318" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1522506318"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -12,17 +12,17 @@
<title>Creating messages :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1517057321" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1517057321" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1517057321" rel="stylesheet">
<link href="/lettre/css/theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1522506318" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1522506318" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1522506318" rel="stylesheet">
<link href="/lettre/css/theme.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1522506318" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1517057321"></script>
<script src="/lettre/js/jquery-2.x.min.js?1522506318"></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?1517057321"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1522506318"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1522506318"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/search.js?1522506318"></script>
</div>
@@ -608,20 +608,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?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1517057321"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1517057321"></script>
<script src="/lettre/js/featherlight.min.js?1517057321"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1517057321"></script>
<script src="/lettre/js/highlight.pack.js?1517057321"></script>
<script src="/lettre/js/clipboard.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1522506318"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1522506318"></script>
<script src="/lettre/js/featherlight.min.js?1522506318"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1522506318"></script>
<script src="/lettre/js/highlight.pack.js?1522506318"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1517057321"></script>
<script src="/lettre/js/learn.js?1517057321"></script>
<script src="/lettre/js/hugo-learn.js?1517057321"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1522506318"></script>
<script src="/lettre/js/learn.js?1522506318"></script>
<script src="/lettre/js/hugo-learn.js?1522506318"></script>
<link href="/lettre/mermaid/mermaid.css?1517057321" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1517057321"></script>
<link href="/lettre/mermaid/mermaid.css?1522506318" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1522506318"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -12,17 +12,17 @@
<title>Getting started :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1517057321" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1517057321" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1517057321" rel="stylesheet">
<link href="/lettre/css/theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1522506318" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1522506318" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1522506318" rel="stylesheet">
<link href="/lettre/css/theme.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1522506318" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1517057321"></script>
<script src="/lettre/js/jquery-2.x.min.js?1522506318"></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?1517057321"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1522506318"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1522506318"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/search.js?1522506318"></script>
</div>
@@ -605,20 +605,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?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1517057321"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1517057321"></script>
<script src="/lettre/js/featherlight.min.js?1517057321"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1517057321"></script>
<script src="/lettre/js/highlight.pack.js?1517057321"></script>
<script src="/lettre/js/clipboard.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1522506318"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1522506318"></script>
<script src="/lettre/js/featherlight.min.js?1522506318"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1522506318"></script>
<script src="/lettre/js/highlight.pack.js?1522506318"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1517057321"></script>
<script src="/lettre/js/learn.js?1517057321"></script>
<script src="/lettre/js/hugo-learn.js?1517057321"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1522506318"></script>
<script src="/lettre/js/learn.js?1522506318"></script>
<script src="/lettre/js/hugo-learn.js?1522506318"></script>
<link href="/lettre/mermaid/mermaid.css?1517057321" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1517057321"></script>
<link href="/lettre/mermaid/mermaid.css?1522506318" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1522506318"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -12,17 +12,17 @@
<title>Introduction :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1517057321" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1517057321" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1517057321" rel="stylesheet">
<link href="/lettre/css/theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1522506318" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1522506318" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1522506318" rel="stylesheet">
<link href="/lettre/css/theme.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1522506318" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1517057321"></script>
<script src="/lettre/js/jquery-2.x.min.js?1522506318"></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?1517057321"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1522506318"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1522506318"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/search.js?1522506318"></script>
</div>
@@ -611,20 +611,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?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1517057321"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1517057321"></script>
<script src="/lettre/js/featherlight.min.js?1517057321"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1517057321"></script>
<script src="/lettre/js/highlight.pack.js?1517057321"></script>
<script src="/lettre/js/clipboard.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1522506318"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1522506318"></script>
<script src="/lettre/js/featherlight.min.js?1522506318"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1522506318"></script>
<script src="/lettre/js/highlight.pack.js?1522506318"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1517057321"></script>
<script src="/lettre/js/learn.js?1517057321"></script>
<script src="/lettre/js/hugo-learn.js?1517057321"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1522506318"></script>
<script src="/lettre/js/learn.js?1522506318"></script>
<script src="/lettre/js/hugo-learn.js?1522506318"></script>
<link href="/lettre/mermaid/mermaid.css?1517057321" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1517057321"></script>
<link href="/lettre/mermaid/mermaid.css?1522506318" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1522506318"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -32,7 +32,7 @@
{
"uri": "/content/sending-messages/file",
"title": "File transport",
"content": "\nThe file transport writes the emails to the given directory. The name of the file will be\nmessage_id.txt.\nIt can be useful for testing purposes, or if you want to keep track of sent messages.\n\nextern crate lettre;\n\nuse std::env::temp_dir;\n\nuse lettre::file::FileEmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};\n\nfn main() {\n // Write to the local temp directory\n let mut sender = FileEmailTransport::new(temp_dir());\n let 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 let result = sender.send(&email);\n assert!(result.is_ok());\n}\n\nExample result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt:\n\nb7c211bc-9811-45ce-8cd9-68eab575d695: from=user@localhost to=root@localhost\nTo: root@localhost\nFrom: user@localhost\nSubject: Hello\nDate: Sat, 31 Oct 2015 13:42:19 +0100\nMessage-ID: b7c211bc-9811-45ce-8cd9-68eab575d695.lettre@localhost\n\nHello World!\n",
"content": "\nThe file transport writes the emails to the given directory. The name of the file will be\nmessage_id.txt.\nIt can be useful for testing purposes, or if you want to keep track of sent messages.\n\nextern crate lettre;\n\nuse std::env::temp_dir;\n\nuse lettre::file::FileEmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport};\n\nfn main() {\n // Write to the local temp directory\n let mut sender = FileEmailTransport::new(temp_dir());\n let email = SimpleSendableEmail::new(\n \"user@localhost\".to_string(),\n &[\"root@localhost\".to_string()],\n \"messageid\".tostring(),\n \"Hello world\".to_string(),\n ).unwrap();\n \n let result = sender.send(&email);\n assert!(result.is_ok());\n}\n\nExample result in /tmp/b7c211bc-9811-45ce-8cd9-68eab575d695.txt:\n\nb7c211bc-9811-45ce-8cd9-68eab575d695: from=user@localhost to=root@localhost\nTo: root@localhost\nFrom: user@localhost\nSubject: Hello\nDate: Sat, 31 Oct 2015 13:42:19 +0100\nMessage-ID: b7c211bc-9811-45ce-8cd9-68eab575d695.lettre@localhost\n\nHello World!\n",
"tags": []
},
{
@@ -44,19 +44,19 @@
{
"uri": "/content/sending-messages/sendmail",
"title": "Sendmail transport",
"content": "\nThe sendmail transport sends the email using the local sendmail command.\n\nextern crate lettre;\n\nuse lettre::sendmail::SendmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};\n\nfn main() {\n let 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 let mut sender = SendmailTransport::new();\n let result = sender.send(&email);\n assert!(result.is_ok());\n}\n",
"content": "\nThe sendmail transport sends the email using the local sendmail command.\n\nextern crate lettre;\n\nuse lettre::sendmail::SendmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport};\n\nfn main() {\n let email = SimpleSendableEmail::new(\n \"user@localhost\".to_string(),\n &[\"root@localhost\".to_string()],\n \"messageid\".tostring(),\n \"Hello world\".to_string(),\n ).unwrap();\n \n let mut sender = SendmailTransport::new();\n let result = sender.send(&email);\n assert!(result.is_ok());\n}\n",
"tags": []
},
{
"uri": "/content/sending-messages/smtp",
"title": "SMTP transport",
"content": "\nThis transport uses the SMTP protocol to send emails over the network (locally or remotely).\n\nIt is designed to be:\n\nSecured: email are encrypted by default\nModern: Unicode support for email content and sender/recipient addresses 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\nextern crate lettre;\n\nuse lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};\n\nfn main() {\n let 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\n let mut mailer =\n SmtpTransport::builderunencryptedlocalhost().unwrap().build();\n // Send the email\n let result = mailer.send(&email);\n \n assert!(result.is_ok());\n}\n\n Complete example\n\nextern crate lettre;\n\nuse lettre::smtp::authentication::{Credentials, Mechanism};\nuse lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};\nuse lettre::smtp::extension::ClientId;\nuse lettre::smtp::ConnectionReuseParameters;\n\nfn main() {\n let 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\n let mut mailer = SmtpTransport::simple_builder(\"server.tld\").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 \n let result_1 = mailer.send(&email);\n assert!(result1.isok());\n \n // The second email will use the same connection\n let result_2 = mailer.send(&email);\n assert!(result2.isok());\n \n // Explicitly close the SMTP transaction as we enabled connection reuse\n mailer.close();\n}\n\nLower level\n\nYou can also send commands, here is a simple email transaction without\nerror handling:\n\nextern crate lettre;\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\nfn main() {\n let mut email_client: ClientNetworkStream = Client::new();\n let _ = emailclient.connect(&(\"localhost\", SMTPPORT), None);\n let _ = emailclient.command(EhloCommand::new(ClientId::new(\"myhostname\".to_string())));\n let _ = email_client.command(\n MailCommand::new(Some(EmailAddress::new(\"user@example.com\".to_string())), vec![])\n );\n let _ = email_client.command(\n RcptCommand::new(EmailAddress::new(\"user@example.org\".to_string()), vec![])\n );\n let _ = email_client.command(DataCommand);\n let _ = emailclient.message(Box::new(\"Test email\".asbytes()));\n let _ = email_client.command(QuitCommand);\n}\n\n",
"content": "\nThis transport uses the SMTP protocol to send emails over the network (locally or remotely).\n\nIt is designed to be:\n\nSecured: email are encrypted by default\nModern: Unicode support for email content and sender/recipient addresses 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\nextern crate lettre;\n\nuse lettre::{SimpleSendableEmail, EmailTransport, SmtpTransport};\n\nfn main() {\n let email = SimpleSendableEmail::new(\n \"user@localhost\".to_string(),\n &[\"root@localhost\".to_string()],\n \"messageid\".tostring(),\n \"Hello world\".to_string(),\n ).unwrap();\n \n // Open a local connection on port 25\n let mut mailer =\n SmtpTransport::builderunencryptedlocalhost().unwrap().build();\n // Send the email\n let result = mailer.send(&email);\n \n assert!(result.is_ok());\n}\n\n Complete example\n\nextern crate lettre;\n\nuse lettre::smtp::authentication::{Credentials, Mechanism};\nuse lettre::{SimpleSendableEmail, EmailTransport, SmtpTransport};\nuse lettre::smtp::extension::ClientId;\nuse lettre::smtp::ConnectionReuseParameters;\n\nfn main() {\n let email = SimpleSendableEmail::new(\n \"user@localhost\".to_string(),\n &[\"root@localhost\".to_string()],\n \"messageid\".tostring(),\n \"Hello world\".to_string(),\n ).unwrap();\n \n // Connect to a remote server on a custom port\n let mut mailer = SmtpTransport::simple_builder(\"server.tld\").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 \n let result_1 = mailer.send(&email);\n assert!(result1.isok());\n \n // The second email will use the same connection\n let result_2 = mailer.send(&email);\n assert!(result2.isok());\n \n // Explicitly close the SMTP transaction as we enabled connection reuse\n mailer.close();\n}\n\nLower level\n\nYou can also send commands, here is a simple email transaction without\nerror handling:\n\nextern crate lettre;\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\nfn main() {\n let mut email_client: ClientNetworkStream = Client::new();\n let _ = emailclient.connect(&(\"localhost\", SMTPPORT), None);\n let _ = emailclient.command(EhloCommand::new(ClientId::new(\"myhostname\".to_string())));\n let _ = email_client.command(\n MailCommand::new(Some(EmailAddress::new(\"user@example.com\".to_string()).unwrap()), vec![])\n );\n let _ = email_client.command(\n RcptCommand::new(EmailAddress::new(\"user@example.org\".to_string()).unwrap(), vec![])\n );\n let _ = email_client.command(DataCommand);\n let _ = emailclient.message(Box::new(\"Test email\".asbytes()));\n let _ = email_client.command(QuitCommand);\n}\n\n",
"tags": []
},
{
"uri": "/content/sending-messages/stub",
"title": "Stub transport",
"content": "\nThe stub transport only logs message envelope and drops the content. It can be useful for\ntesting purposes.\n\nextern crate lettre;\n\nuse lettre::stub::StubEmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};\n\nfn main() {\n let 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 let mut sender = StubEmailTransport::new_positive();\n let result = sender.send(&email);\n assert!(result.is_ok());\n}\n\nWill log (when using a logger like env_logger):\n\nb7c211bc-9811-45ce-8cd9-68eab575d695: from=user@localhost to=root@localhost\n",
"content": "\nThe stub transport only logs message envelope and drops the content. It can be useful for\ntesting purposes.\n\nextern crate lettre;\n\nuse lettre::stub::StubEmailTransport;\nuse lettre::{SimpleSendableEmail, EmailTransport};\n\nfn main() {\n let email = SimpleSendableEmail::new(\n \"user@localhost\".to_string(),\n &[\"root@localhost\".to_string()],\n \"messageid\".tostring(),\n \"Hello world\".to_string(),\n ).unwrap();\n \n let mut sender = StubEmailTransport::new_positive();\n let result = sender.send(&email);\n assert!(result.is_ok());\n}\n\nWill log (when using a logger like env_logger):\n\nb7c211bc-9811-45ce-8cd9-68eab575d695: from=user@localhost to=root@localhost\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.
extern crate lettre; use lettre::sendmail::SendmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; fn main() { 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!(result.is_ok()); }</description>
extern crate lettre; use lettre::sendmail::SendmailTransport; use lettre::{SimpleSendableEmail, EmailTransport}; fn main() { let email = SimpleSendableEmail::new( &amp;#34;user@localhost&amp;#34;.to_string(), &amp;amp;[&amp;#34;root@localhost&amp;#34;.to_string()], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ).unwrap(); let mut sender = SendmailTransport::new(); let result = sender.send(&amp;amp;email); assert!(result.is_ok()); }</description>
</item>
<item>
@@ -72,7 +72,7 @@ extern crate lettre_email; use lettre_email::EmailBuilder; fn main() { // Create
<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.
extern crate lettre; use std::env::temp_dir; use lettre::file::FileEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; fn main() { // 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;.</description>
extern crate lettre; use std::env::temp_dir; use lettre::file::FileEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport}; fn main() { // Write to the local temp directory let mut sender = FileEmailTransport::new(temp_dir()); let email = SimpleSendableEmail::new( &amp;#34;user@localhost&amp;#34;.to_string(), &amp;amp;[&amp;#34;root@localhost&amp;#34;.to_string()], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ).</description>
</item>
<item>
@@ -82,7 +82,7 @@ extern crate lettre; use std::env::temp_dir; use lettre::file::FileEmailTranspor
<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.
extern crate lettre; use lettre::stub::StubEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; fn main() { 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):
extern crate lettre; use lettre::stub::StubEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport}; fn main() { let email = SimpleSendableEmail::new( &amp;#34;user@localhost&amp;#34;.to_string(), &amp;amp;[&amp;#34;root@localhost&amp;#34;.to_string()], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ).unwrap(); 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>

View File

@@ -12,17 +12,17 @@
<title>File transport :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1517057321" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1517057321" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1517057321" rel="stylesheet">
<link href="/lettre/css/theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1522506318" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1522506318" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1522506318" rel="stylesheet">
<link href="/lettre/css/theme.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1522506318" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1517057321"></script>
<script src="/lettre/js/jquery-2.x.min.js?1522506318"></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?1517057321"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1522506318"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1522506318"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/search.js?1522506318"></script>
</div>
@@ -391,17 +391,17 @@ It can be useful for testing purposes, or if you want to keep track of sent mess
<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:#66d9ef">use</span> lettre::{SimpleSendableEmail, EmailTransport};
<span style="color:#66d9ef">fn</span> <span style="color:#a6e22e">main</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="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;user@localhost&#34;</span>.to_string(),
<span style="color:#f92672">&amp;</span>[<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(),
);
).unwrap();
<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());
@@ -635,20 +635,20 @@ Hello World!</code></pre></div>
<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?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1517057321"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1517057321"></script>
<script src="/lettre/js/featherlight.min.js?1517057321"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1517057321"></script>
<script src="/lettre/js/highlight.pack.js?1517057321"></script>
<script src="/lettre/js/clipboard.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1522506318"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1522506318"></script>
<script src="/lettre/js/featherlight.min.js?1522506318"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1522506318"></script>
<script src="/lettre/js/highlight.pack.js?1522506318"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1517057321"></script>
<script src="/lettre/js/learn.js?1517057321"></script>
<script src="/lettre/js/hugo-learn.js?1517057321"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1522506318"></script>
<script src="/lettre/js/learn.js?1522506318"></script>
<script src="/lettre/js/hugo-learn.js?1522506318"></script>
<link href="/lettre/mermaid/mermaid.css?1517057321" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1517057321"></script>
<link href="/lettre/mermaid/mermaid.css?1522506318" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1522506318"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -12,17 +12,17 @@
<title>Sending messages :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1517057321" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1517057321" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1517057321" rel="stylesheet">
<link href="/lettre/css/theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1522506318" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1522506318" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1522506318" rel="stylesheet">
<link href="/lettre/css/theme.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1522506318" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1517057321"></script>
<script src="/lettre/js/jquery-2.x.min.js?1522506318"></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?1517057321"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1522506318"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1522506318"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/search.js?1522506318"></script>
</div>
@@ -608,20 +608,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?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1517057321"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1517057321"></script>
<script src="/lettre/js/featherlight.min.js?1517057321"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1517057321"></script>
<script src="/lettre/js/highlight.pack.js?1517057321"></script>
<script src="/lettre/js/clipboard.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1522506318"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1522506318"></script>
<script src="/lettre/js/featherlight.min.js?1522506318"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1522506318"></script>
<script src="/lettre/js/highlight.pack.js?1522506318"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1517057321"></script>
<script src="/lettre/js/learn.js?1517057321"></script>
<script src="/lettre/js/hugo-learn.js?1517057321"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1522506318"></script>
<script src="/lettre/js/learn.js?1522506318"></script>
<script src="/lettre/js/hugo-learn.js?1522506318"></script>
<link href="/lettre/mermaid/mermaid.css?1517057321" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1517057321"></script>
<link href="/lettre/mermaid/mermaid.css?1522506318" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1522506318"></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.
extern crate lettre; use lettre::sendmail::SendmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; fn main() { 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!(result.is_ok()); }</description>
extern crate lettre; use lettre::sendmail::SendmailTransport; use lettre::{SimpleSendableEmail, EmailTransport}; fn main() { let email = SimpleSendableEmail::new( &amp;#34;user@localhost&amp;#34;.to_string(), &amp;amp;[&amp;#34;root@localhost&amp;#34;.to_string()], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ).unwrap(); let mut sender = SendmailTransport::new(); let result = sender.send(&amp;amp;email); assert!(result.is_ok()); }</description>
</item>
<item>
@@ -51,7 +51,7 @@ extern crate lettre; use lettre::sendmail::SendmailTransport; use lettre::{Simpl
<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.
extern crate lettre; use std::env::temp_dir; use lettre::file::FileEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; fn main() { // 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;.</description>
extern crate lettre; use std::env::temp_dir; use lettre::file::FileEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport}; fn main() { // Write to the local temp directory let mut sender = FileEmailTransport::new(temp_dir()); let email = SimpleSendableEmail::new( &amp;#34;user@localhost&amp;#34;.to_string(), &amp;amp;[&amp;#34;root@localhost&amp;#34;.to_string()], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ).</description>
</item>
<item>
@@ -61,7 +61,7 @@ extern crate lettre; use std::env::temp_dir; use lettre::file::FileEmailTranspor
<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.
extern crate lettre; use lettre::stub::StubEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress}; fn main() { 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):
extern crate lettre; use lettre::stub::StubEmailTransport; use lettre::{SimpleSendableEmail, EmailTransport}; fn main() { let email = SimpleSendableEmail::new( &amp;#34;user@localhost&amp;#34;.to_string(), &amp;amp;[&amp;#34;root@localhost&amp;#34;.to_string()], &amp;#34;message_id&amp;#34;.to_string(), &amp;#34;Hello world&amp;#34;.to_string(), ).unwrap(); 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>

View File

@@ -12,17 +12,17 @@
<title>Introduction :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1517057321" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1517057321" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1517057321" rel="stylesheet">
<link href="/lettre/css/theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1522506318" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1522506318" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1522506318" rel="stylesheet">
<link href="/lettre/css/theme.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1522506318" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1517057321"></script>
<script src="/lettre/js/jquery-2.x.min.js?1522506318"></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?1517057321"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1522506318"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1522506318"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/search.js?1522506318"></script>
</div>
@@ -616,20 +616,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?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1517057321"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1517057321"></script>
<script src="/lettre/js/featherlight.min.js?1517057321"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1517057321"></script>
<script src="/lettre/js/highlight.pack.js?1517057321"></script>
<script src="/lettre/js/clipboard.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1522506318"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1522506318"></script>
<script src="/lettre/js/featherlight.min.js?1522506318"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1522506318"></script>
<script src="/lettre/js/highlight.pack.js?1522506318"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1517057321"></script>
<script src="/lettre/js/learn.js?1517057321"></script>
<script src="/lettre/js/hugo-learn.js?1517057321"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1522506318"></script>
<script src="/lettre/js/learn.js?1522506318"></script>
<script src="/lettre/js/hugo-learn.js?1522506318"></script>
<link href="/lettre/mermaid/mermaid.css?1517057321" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1517057321"></script>
<link href="/lettre/mermaid/mermaid.css?1522506318" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1522506318"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -12,17 +12,17 @@
<title>Sendmail transport :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1517057321" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1517057321" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1517057321" rel="stylesheet">
<link href="/lettre/css/theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1522506318" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1522506318" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1522506318" rel="stylesheet">
<link href="/lettre/css/theme.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1522506318" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1517057321"></script>
<script src="/lettre/js/jquery-2.x.min.js?1522506318"></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?1517057321"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1522506318"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1522506318"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/search.js?1522506318"></script>
</div>
@@ -387,15 +387,15 @@
<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,no_run" data-lang="rust,no_run">extern crate lettre;
use lettre::sendmail::SendmailTransport;
use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
use lettre::{SimpleSendableEmail, EmailTransport};
fn main() {
let email = SimpleSendableEmail::new(
EmailAddress::new(&#34;user@localhost&#34;.to_string()),
vec![EmailAddress::new(&#34;root@localhost&#34;.to_string())],
&#34;user@localhost&#34;.to_string(),
&amp;[&#34;root@localhost&#34;.to_string()],
&#34;message_id&#34;.to_string(),
&#34;Hello world&#34;.to_string(),
);
).unwrap();
let mut sender = SendmailTransport::new();
let result = sender.send(&amp;email);
@@ -621,20 +621,20 @@ fn main() {
<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?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1517057321"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1517057321"></script>
<script src="/lettre/js/featherlight.min.js?1517057321"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1517057321"></script>
<script src="/lettre/js/highlight.pack.js?1517057321"></script>
<script src="/lettre/js/clipboard.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1522506318"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1522506318"></script>
<script src="/lettre/js/featherlight.min.js?1522506318"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1522506318"></script>
<script src="/lettre/js/highlight.pack.js?1522506318"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1517057321"></script>
<script src="/lettre/js/learn.js?1517057321"></script>
<script src="/lettre/js/hugo-learn.js?1517057321"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1522506318"></script>
<script src="/lettre/js/learn.js?1522506318"></script>
<script src="/lettre/js/hugo-learn.js?1522506318"></script>
<link href="/lettre/mermaid/mermaid.css?1517057321" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1517057321"></script>
<link href="/lettre/mermaid/mermaid.css?1522506318" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1522506318"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -12,17 +12,17 @@
<title>SMTP transport :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1517057321" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1517057321" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1517057321" rel="stylesheet">
<link href="/lettre/css/theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1522506318" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1522506318" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1522506318" rel="stylesheet">
<link href="/lettre/css/theme.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1522506318" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1517057321"></script>
<script src="/lettre/js/jquery-2.x.min.js?1522506318"></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?1517057321"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1522506318"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1522506318"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/search.js?1522506318"></script>
</div>
@@ -420,15 +420,15 @@ emails directly to the destination.</p>
<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,no_run" data-lang="rust,no_run">extern crate lettre;
use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};
use lettre::{SimpleSendableEmail, EmailTransport, SmtpTransport};
fn main() {
let email = SimpleSendableEmail::new(
EmailAddress::new(&#34;user@localhost&#34;.to_string()),
vec![EmailAddress::new(&#34;root@localhost&#34;.to_string())],
&#34;user@localhost&#34;.to_string(),
&amp;[&#34;root@localhost&#34;.to_string()],
&#34;message_id&#34;.to_string(),
&#34;Hello world&#34;.to_string(),
);
).unwrap();
// Open a local connection on port 25
let mut mailer =
@@ -442,17 +442,17 @@ fn main() {
<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,no_run" data-lang="rust,no_run">extern crate lettre;
use lettre::smtp::authentication::{Credentials, Mechanism};
use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};
use lettre::{SimpleSendableEmail, EmailTransport, SmtpTransport};
use lettre::smtp::extension::ClientId;
use lettre::smtp::ConnectionReuseParameters;
fn main() {
let email = SimpleSendableEmail::new(
EmailAddress::new(&#34;user@localhost&#34;.to_string()),
vec![EmailAddress::new(&#34;root@localhost&#34;.to_string())],
&#34;user@localhost&#34;.to_string(),
&amp;[&#34;root@localhost&#34;.to_string()],
&#34;message_id&#34;.to_string(),
&#34;Hello world&#34;.to_string(),
);
).unwrap();
// Connect to a remote server on a custom port
let mut mailer = SmtpTransport::simple_builder(&#34;server.tld&#34;).unwrap()
@@ -495,10 +495,10 @@ fn main() {
let _ = email_client.connect(&amp;(&#34;localhost&#34;, SMTP_PORT), None);
let _ = email_client.command(EhloCommand::new(ClientId::new(&#34;my_hostname&#34;.to_string())));
let _ = email_client.command(
MailCommand::new(Some(EmailAddress::new(&#34;user@example.com&#34;.to_string())), vec![])
MailCommand::new(Some(EmailAddress::new(&#34;user@example.com&#34;.to_string()).unwrap()), vec![])
);
let _ = email_client.command(
RcptCommand::new(EmailAddress::new(&#34;user@example.org&#34;.to_string()), vec![])
RcptCommand::new(EmailAddress::new(&#34;user@example.org&#34;.to_string()).unwrap(), vec![])
);
let _ = email_client.command(DataCommand);
let _ = email_client.message(Box::new(&#34;Test email&#34;.as_bytes()));
@@ -724,20 +724,20 @@ fn main() {
<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?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1517057321"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1517057321"></script>
<script src="/lettre/js/featherlight.min.js?1517057321"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1517057321"></script>
<script src="/lettre/js/highlight.pack.js?1517057321"></script>
<script src="/lettre/js/clipboard.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1522506318"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1522506318"></script>
<script src="/lettre/js/featherlight.min.js?1522506318"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1522506318"></script>
<script src="/lettre/js/highlight.pack.js?1522506318"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1517057321"></script>
<script src="/lettre/js/learn.js?1517057321"></script>
<script src="/lettre/js/hugo-learn.js?1517057321"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1522506318"></script>
<script src="/lettre/js/learn.js?1522506318"></script>
<script src="/lettre/js/hugo-learn.js?1522506318"></script>
<link href="/lettre/mermaid/mermaid.css?1517057321" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1517057321"></script>
<link href="/lettre/mermaid/mermaid.css?1522506318" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1522506318"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -12,17 +12,17 @@
<title>Stub transport :: Lettre site</title>
<link href="/lettre/css/nucleus.css?1517057321" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1517057321" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1517057321" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1517057321" rel="stylesheet">
<link href="/lettre/css/theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1517057321" rel="stylesheet">
<link href="/lettre/css/nucleus.css?1522506318" rel="stylesheet">
<link href="/lettre/css/font-awesome.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hybrid.css?1522506318" rel="stylesheet">
<link href="/lettre/css/featherlight.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/perfect-scrollbar.min.css?1522506318" rel="stylesheet">
<link href="/lettre/css/auto-complete.css?1522506318" rel="stylesheet">
<link href="/lettre/css/theme.css?1522506318" rel="stylesheet">
<link href="/lettre/css/hugo-theme.css?1522506318" rel="stylesheet">
<script src="/lettre/js/jquery-2.x.min.js?1517057321"></script>
<script src="/lettre/js/jquery-2.x.min.js?1522506318"></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?1517057321"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/lunr.min.js?1522506318"></script>
<script type="text/javascript" src="/lettre/js/auto-complete.js?1522506318"></script>
<script type="text/javascript">
var baseurl = "https:\/\/lettre.github.io\/lettre";
</script>
<script type="text/javascript" src="/lettre/js/search.js?1517057321"></script>
<script type="text/javascript" src="/lettre/js/search.js?1522506318"></script>
</div>
@@ -388,15 +388,15 @@ 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">extern</span> <span style="color:#66d9ef">crate</span> lettre;
<span style="color:#66d9ef">use</span> lettre::stub::StubEmailTransport;
<span style="color:#66d9ef">use</span> lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
<span style="color:#66d9ef">use</span> lettre::{SimpleSendableEmail, EmailTransport};
<span style="color:#66d9ef">fn</span> <span style="color:#a6e22e">main</span>() {
<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;user@localhost&#34;</span>.to_string(),
<span style="color:#f92672">&amp;</span>[<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(),
);
).unwrap();
<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);
@@ -621,20 +621,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?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1517057321"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1517057321"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1517057321"></script>
<script src="/lettre/js/featherlight.min.js?1517057321"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1517057321"></script>
<script src="/lettre/js/highlight.pack.js?1517057321"></script>
<script src="/lettre/js/clipboard.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.min.js?1522506318"></script>
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1522506318"></script>
<script src="/lettre/js/jquery.sticky-kit.min.js?1522506318"></script>
<script src="/lettre/js/featherlight.min.js?1522506318"></script>
<script src="/lettre/js/html5shiv-printshiv.min.js?1522506318"></script>
<script src="/lettre/js/highlight.pack.js?1522506318"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/lettre/js/modernizr.custom.71422.js?1517057321"></script>
<script src="/lettre/js/learn.js?1517057321"></script>
<script src="/lettre/js/hugo-learn.js?1517057321"></script>
<script src="/lettre/js/modernizr.custom.71422.js?1522506318"></script>
<script src="/lettre/js/learn.js?1522506318"></script>
<script src="/lettre/js/hugo-learn.js?1522506318"></script>
<link href="/lettre/mermaid/mermaid.css?1517057321" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1517057321"></script>
<link href="/lettre/mermaid/mermaid.css?1522506318" type="text/css" rel="stylesheet" />
<script src="/lettre/mermaid/mermaid.js?1522506318"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>

View File

@@ -11,6 +11,10 @@
* Detail in SMTP Response is now an enum
* Use nom for parsing smtp responses
* `Envelope` was moved from `lettre_email` to `lettre`
* `EmailAddress::new()` now returns a `Result`
* `SendableEmail` replaces `from` and `to` by `envelope` that returns an `Envelope`
* `File` transport storage format has changed
#### Removed

View File

@@ -1,17 +1,17 @@
extern crate env_logger;
extern crate lettre;
use lettre::{EmailAddress, EmailTransport, SimpleSendableEmail, SmtpTransport};
use lettre::{EmailTransport, SimpleSendableEmail, SmtpTransport};
fn main() {
env_logger::init();
let email = SimpleSendableEmail::new(
EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"file_id".to_string(),
"user@localhost".to_string(),
&["root@localhost".to_string()],
"my-message-id".to_string(),
"Hello ß☺ example".to_string(),
);
).unwrap();
// Open a local connection on port 25
let mut mailer = SmtpTransport::builder_unencrypted_localhost()

View File

@@ -40,10 +40,9 @@ impl<'a, T: Read + 'a> EmailTransport<'a, T, FileResult> for FileEmailTransport
let mut message_content = String::new();
let _ = email.message().read_to_string(&mut message_content);
let simple_email = SimpleSendableEmail::new(
email.from().clone(),
email.to().clone(),
email.message_id().clone(),
let simple_email = SimpleSendableEmail::new_with_envelope(
email.envelope().clone(),
email.message_id().to_string(),
message_content,
);

View File

@@ -48,11 +48,63 @@ pub use smtp::{ClientSecurity, SmtpTransport};
pub use smtp::client::net::ClientTlsParameters;
use std::fmt::{self, Display, Formatter};
use std::io::Read;
use std::error::Error as StdError;
use std::str::FromStr;
/// Error type for email content
#[derive(Debug)]
pub enum Error {
/// Missing from in envelope
MissingFrom,
/// Missing to in envelope
MissingTo,
/// Invalid email
InvalidEmailAddress,
}
impl StdError for Error {
fn description(&self) -> &str {
match *self {
Error::MissingFrom => "missing source address, invalid envelope",
Error::MissingTo => "missing destination address, invalid envelope",
Error::InvalidEmailAddress => "invalid email address",
}
}
fn cause(&self) -> Option<&StdError> {
None
}
}
impl Display for Error {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
fmt.write_str(self.description())
}
}
/// Email result type
pub type EmailResult<T> = Result<T, Error>;
/// Email address
#[derive(PartialEq, Eq, Clone, Debug)]
#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))]
pub struct EmailAddress(pub String);
pub struct EmailAddress(String);
impl EmailAddress {
/// Creates a new `EmailAddress`. For now it makes no validation.
pub fn new(address: String) -> EmailResult<EmailAddress> {
// TODO make some basic sanity checks
Ok(EmailAddress(address))
}
}
impl FromStr for EmailAddress {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
EmailAddress::new(s.to_string())
}
}
impl Display for EmailAddress {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
@@ -60,19 +112,98 @@ impl Display for EmailAddress {
}
}
impl EmailAddress {
/// Creates a new email address
pub fn new(address: String) -> EmailAddress {
EmailAddress(address)
/// Simple email envelope representation
///
/// We only accept mailboxes, and do not support source routes (as per RFC).
#[derive(PartialEq, Eq, Clone, Debug)]
#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))]
pub struct Envelope {
/// The envelope recipients' addresses
///
/// This can not be empty.
forward_path: Vec<EmailAddress>,
/// The envelope sender address
reverse_path: Option<EmailAddress>,
}
impl Envelope {
/// Creates a new envelope, which may fail if `to` is empty.
pub fn new(from: Option<EmailAddress>, to: Vec<EmailAddress>) -> EmailResult<Envelope> {
if to.is_empty() {
return Err(Error::MissingTo);
}
Ok(Envelope {
forward_path: to,
reverse_path: from,
})
}
/// Destination addresses of the envelope
pub fn to(&self) -> &[EmailAddress] {
self.forward_path.as_slice()
}
/// Source address of the envelope
pub fn from(&self) -> Option<&EmailAddress> {
self.reverse_path.as_ref()
}
/// Creates a new builder
pub fn builder() -> EnvelopeBuilder {
EnvelopeBuilder::new()
}
}
/// Simple email envelope representation
#[derive(PartialEq, Eq, Clone, Debug, Default)]
pub struct EnvelopeBuilder {
/// The envelope recipients' addresses
to: Vec<EmailAddress>,
/// The envelope sender address
from: Option<EmailAddress>,
}
impl EnvelopeBuilder {
/// Constructs an envelope with no recipients and an empty sender
pub fn new() -> Self {
EnvelopeBuilder {
to: vec![],
from: None,
}
}
/// Adds a recipient
pub fn to<S: Into<EmailAddress>>(mut self, address: S) -> Self {
self.add_to(address);
self
}
/// Adds a recipient
pub fn add_to<S: Into<EmailAddress>>(&mut self, address: S) {
self.to.push(address.into());
}
/// Sets the sender
pub fn from<S: Into<EmailAddress>>(mut self, address: S) -> Self {
self.set_from(address);
self
}
/// Sets the sender
pub fn set_from<S: Into<EmailAddress>>(&mut self, address: S) {
self.from = Some(address.into());
}
/// Build the envelope
pub fn build(self) -> EmailResult<Envelope> {
Envelope::new(self.from, self.to)
}
}
/// Email sendable by an SMTP client
pub trait SendableEmail<'a, T: Read + 'a> {
/// To
fn to(&self) -> Vec<EmailAddress>;
/// From
fn from(&self) -> EmailAddress;
/// Envelope
fn envelope(&self) -> Envelope;
/// Message ID, used for logging
fn message_id(&self) -> String;
/// Message content
@@ -89,10 +220,8 @@ pub trait EmailTransport<'a, U: Read + 'a, V> {
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))]
pub struct SimpleSendableEmail {
/// To
to: Vec<EmailAddress>,
/// From
from: EmailAddress,
/// Envelope
envelope: Envelope,
/// Message ID
message_id: String,
/// Message content
@@ -102,14 +231,30 @@ pub struct SimpleSendableEmail {
impl SimpleSendableEmail {
/// Returns a new email
pub fn new(
from_address: EmailAddress,
to_addresses: Vec<EmailAddress>,
from_address: String,
to_addresses: &[String],
message_id: String,
message: String,
) -> EmailResult<SimpleSendableEmail> {
let to: Result<Vec<EmailAddress>, Error> = to_addresses
.iter()
.map(|x| EmailAddress::new(x.clone()))
.collect();
Ok(SimpleSendableEmail::new_with_envelope(
Envelope::new(Some(EmailAddress::new(from_address)?), to?)?,
message_id,
message,
))
}
/// Returns a new email from a valid envelope
pub fn new_with_envelope(
envelope: Envelope,
message_id: String,
message: String,
) -> SimpleSendableEmail {
SimpleSendableEmail {
from: from_address,
to: to_addresses,
envelope,
message_id,
message: message.into_bytes(),
}
@@ -117,12 +262,8 @@ impl SimpleSendableEmail {
}
impl<'a> SendableEmail<'a, &'a [u8]> for SimpleSendableEmail {
fn to(&self) -> Vec<EmailAddress> {
self.to.clone()
}
fn from(&self) -> EmailAddress {
self.from.clone()
fn envelope(&self) -> Envelope {
self.envelope.clone()
}
fn message_id(&self) -> String {

View File

@@ -33,13 +33,18 @@ impl SendmailTransport {
impl<'a, T: Read + 'a> EmailTransport<'a, T, SendmailResult> for SendmailTransport {
fn send<U: SendableEmail<'a, T> + 'a>(&mut self, email: &'a U) -> SendmailResult {
let envelope = email.envelope();
// Spawn the sendmail command
let to_addresses: Vec<String> = email.to().iter().map(|x| x.to_string()).collect();
let to_addresses: Vec<String> = envelope.to().iter().map(|x| x.to_string()).collect();
let mut process = Command::new(&self.command)
.args(&[
"-i",
"-f",
&email.from().to_string(),
&match envelope.from() {
Some(address) => address.to_string(),
None => "\"\"".to_string(),
},
&to_addresses.join(" "),
])
.stdin(Stdio::piped())

View File

@@ -307,7 +307,7 @@ mod test {
#[test]
fn test_display() {
let id = ClientId::Domain("localhost".to_string());
let email = EmailAddress::new("test@example.com".to_string());
let email = EmailAddress::new("test@example.com".to_string()).unwrap();
let mail_parameter = MailParameter::Other {
keyword: "TEST".to_string(),
value: Some("value".to_string()),

View File

@@ -308,6 +308,7 @@ impl<'a, T: Read + 'a> EmailTransport<'a, T, SmtpResult> for SmtpTransport {
fn send<U: SendableEmail<'a, T> + 'a>(&mut self, email: &'a U) -> SmtpResult {
// Extract email information
let message_id = email.message_id();
let envelope = email.envelope();
// Check if the connection is still available
if (self.state.connection_reuse_count > 0) && (!self.client.is_connected()) {
@@ -413,15 +414,22 @@ impl<'a, T: Read + 'a> EmailTransport<'a, T, SmtpResult> for SmtpTransport {
try_smtp!(
self.client
.command(MailCommand::new(Some(email.from().clone()), mail_options,)),
.command(MailCommand::new(envelope.from().cloned(), mail_options,)),
self
);
// Log the mail command
info!("{}: from=<{}>", message_id, email.from());
info!(
"{}: from=<{}>",
message_id,
match envelope.from() {
Some(address) => address.to_string(),
None => "".to_string(),
}
);
// Recipient
for to_address in &email.to() {
for to_address in envelope.to() {
try_smtp!(
self.client
.command(RcptCommand::new(to_address.clone(), vec![]),),

View File

@@ -53,16 +53,26 @@ 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 {

View File

@@ -29,11 +29,15 @@ pub type StubResult = Result<(), ()>;
impl<'a, T: Read + 'a> EmailTransport<'a, T, StubResult> for StubEmailTransport {
fn send<U: SendableEmail<'a, T>>(&mut self, email: &'a U) -> StubResult {
let envelope = email.envelope();
info!(
"{}: from=<{}> to=<{:?}>",
email.message_id(),
email.from(),
email.to()
match envelope.from() {
Some(address) => address.to_string(),
None => "".to_string(),
},
envelope.to()
);
self.response
}

View File

@@ -4,7 +4,7 @@ extern crate lettre;
#[cfg(feature = "file-transport")]
mod test {
use lettre::{EmailAddress, EmailTransport, SendableEmail, SimpleSendableEmail};
use lettre::{EmailTransport, SendableEmail, SimpleSendableEmail};
use lettre::file::FileEmailTransport;
use std::env::temp_dir;
use std::fs::File;
@@ -15,11 +15,11 @@ mod test {
fn file_transport() {
let mut sender = FileEmailTransport::new(temp_dir());
let email = SimpleSendableEmail::new(
EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"user@localhost".to_string(),
&["root@localhost".to_string()],
"file_id".to_string(),
"Hello file".to_string(),
);
).unwrap();
let result = sender.send(&email);
assert!(result.is_ok());
@@ -31,8 +31,7 @@ mod test {
assert_eq!(
buffer,
"{\"to\":[\"root@localhost\"],\"from\":\"user@localhost\",\"message_id\":\
\"file_id\",\"message\":[72,101,108,108,111,32,102,105,108,101]}"
"{\"envelope\":{\"forward_path\":[\"root@localhost\"],\"reverse_path\":\"user@localhost\"},\"message_id\":\"file_id\",\"message\":[72,101,108,108,111,32,102,105,108,101]}"
);
remove_file(file).unwrap();

View File

@@ -4,18 +4,18 @@ extern crate lettre;
#[cfg(feature = "sendmail-transport")]
mod test {
use lettre::{EmailAddress, EmailTransport, SimpleSendableEmail};
use lettre::{EmailTransport, SimpleSendableEmail};
use lettre::sendmail::SendmailTransport;
#[test]
fn sendmail_transport_simple() {
let mut sender = SendmailTransport::new();
let email = SimpleSendableEmail::new(
EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"user@localhost".to_string(),
&["root@localhost".to_string()],
"sendmail_id".to_string(),
"Hello sendmail".to_string(),
);
).unwrap();
let result = sender.send(&email);
println!("{:?}", result);

View File

@@ -4,7 +4,7 @@ extern crate lettre;
#[cfg(feature = "smtp-transport")]
mod test {
use lettre::{ClientSecurity, EmailAddress, EmailTransport, SimpleSendableEmail, SmtpTransport};
use lettre::{ClientSecurity, EmailTransport, SimpleSendableEmail, SmtpTransport};
#[test]
fn smtp_transport_simple() {
@@ -12,11 +12,11 @@ mod test {
.unwrap()
.build();
let email = SimpleSendableEmail::new(
EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"user@localhost".to_string(),
&["root@localhost".to_string()],
"smtp_id".to_string(),
"Hello smtp".to_string(),
);
).unwrap();
sender.send(&email).unwrap();
}

View File

@@ -1,19 +1,18 @@
extern crate lettre;
use lettre::{EmailAddress, EmailTransport, SimpleSendableEmail};
use lettre::{EmailTransport, SimpleSendableEmail};
use lettre::stub::StubEmailTransport;
#[test]
fn stub_transport() {
let mut sender_ok = StubEmailTransport::new_positive();
let mut sender_ko = StubEmailTransport::new(Err(()));
let email = SimpleSendableEmail::new(
EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"user@localhost".to_string(),
&["root@localhost".to_string()],
"stub_id".to_string(),
"Hello stub".to_string(),
);
).unwrap();
sender_ok.send(&email).unwrap();
sender_ko.send(&email).unwrap_err();

View File

@@ -7,6 +7,10 @@
* Add tests for the doc using skeptic
* Added a code of conduct
#### Changed
* `Envelope` was moved from `lettre_email` to `lettre`
#### Fixed
* Add missing "Bcc" headers when building the email

View File

@@ -5,13 +5,13 @@ use std::error::Error as StdError;
use std::fmt::{self, Display, Formatter};
use std::io;
use lettre;
/// An enum of all error kinds.
#[derive(Debug)]
pub enum Error {
/// Missing sender
MissingFrom,
/// Missing recipient
MissingTo,
/// Envelope error
Email(lettre::Error),
/// Unparseable filename for attachment
CannotParseFilename,
/// IO error
@@ -27,8 +27,7 @@ impl Display for Error {
impl StdError for Error {
fn description(&self) -> &str {
match *self {
MissingFrom => "the sender is missing",
MissingTo => "the recipient is missing",
Email(ref err) => err.description(),
CannotParseFilename => "the attachment filename could not be parsed",
Io(ref err) => err.description(),
}
@@ -40,3 +39,9 @@ impl From<io::Error> for Error {
Io(err)
}
}
impl From<lettre::Error> for Error {
fn from(err: lettre::Error) -> Error {
Email(err)
}
}

View File

@@ -15,13 +15,14 @@ pub mod error;
pub use email_format::{Address, Header, Mailbox, MimeMessage, MimeMultipartType};
use error::Error;
use lettre::{EmailAddress, SendableEmail};
use lettre::{EmailAddress, Envelope, Error as EmailError, SendableEmail};
use mime::Mime;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use time::{now, Tm};
use uuid::Uuid;
use std::str::FromStr;
/// Converts an address or an address with an alias to a `Header`
pub trait IntoHeader {
@@ -295,43 +296,6 @@ pub struct EmailBuilder {
date_issued: bool,
}
/// Simple email enveloppe representation
#[derive(PartialEq, Eq, Clone, Debug, Default)]
pub struct Envelope {
/// The envelope recipients' addresses
pub to: Vec<String>,
/// The envelope sender address
pub from: String,
}
impl Envelope {
/// Constructs an envelope with no receivers and an empty sender
pub fn new() -> Self {
Envelope {
to: vec![],
from: String::new(),
}
}
/// Adds a receiver
pub fn to<S: Into<String>>(mut self, address: S) -> Self {
self.add_to(address);
self
}
/// Adds a receiver
pub fn add_to<S: Into<String>>(&mut self, address: S) {
self.to.push(address.into());
}
/// Sets the sender
pub fn from<S: Into<String>>(mut self, address: S) -> Self {
self.set_from(address);
self
}
/// Sets the sender
pub fn set_from<S: Into<String>>(&mut self, address: S) {
self.from = address.into();
}
}
/// Simple email representation
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Email {
@@ -753,7 +717,7 @@ impl EmailBuilder {
Some(e) => e,
None => {
// we need to generate the envelope
let mut e = Envelope::new();
let mut e = Envelope::builder();
// add all receivers in to_header and cc_header
for receiver in self.to_header
.iter()
@@ -761,16 +725,13 @@ impl EmailBuilder {
.chain(self.bcc_header.iter())
{
match *receiver {
Address::Mailbox(ref m) => e.add_to(m.address.clone()),
Address::Mailbox(ref m) => e.add_to(EmailAddress::from_str(&m.address)?),
Address::Group(_, ref ms) => for m in ms.iter() {
e.add_to(m.address.clone());
e.add_to(EmailAddress::from_str(&m.address.clone())?);
},
}
}
if e.to.is_empty() {
return Err(Error::MissingTo);
}
e.set_from(match self.sender_header {
e.set_from(EmailAddress::from_str(&match self.sender_header {
Some(x) => x.address.clone(), // if we have a sender_header, use it
None => {
// use a from header
@@ -783,15 +744,15 @@ impl EmailBuilder {
// if it's an author group, use the first author
Some(mailbox) => mailbox.address.clone(),
// for an empty author group (the rarest of the rare cases)
None => return Err(Error::MissingFrom), // empty envelope sender
None => return Err(Error::Email(EmailError::MissingFrom)), // empty envelope sender
},
},
// if we don't have a from header
None => return Err(Error::MissingFrom), // empty envelope sender
None => return Err(Error::Email(EmailError::MissingFrom)), // empty envelope sender
}
}
});
e
})?);
e.build()?
}
};
// Add the collected addresses as mailbox-list all at once.
@@ -804,7 +765,7 @@ impl EmailBuilder {
self.message
.add_header(Header::new_with_value("From".into(), self.from_header).unwrap());
} else {
return Err(Error::MissingFrom);
return Err(Error::Email(EmailError::MissingFrom));
}
if !self.cc_header.is_empty() {
self.message
@@ -845,20 +806,12 @@ impl EmailBuilder {
}
impl<'a> SendableEmail<'a, &'a [u8]> for Email {
fn to(&self) -> Vec<EmailAddress> {
self.envelope
.to
.iter()
.map(|x| EmailAddress::new(x.clone()))
.collect()
}
fn from(&self) -> EmailAddress {
EmailAddress::new(self.envelope.from.clone())
fn envelope(&self) -> Envelope {
self.envelope.clone()
}
fn message_id(&self) -> String {
format!("{}", self.message_id)
self.message_id.to_string()
}
fn message(&'a self) -> Box<&[u8]> {
@@ -975,14 +928,17 @@ mod test {
.build()
.unwrap();
assert_eq!(email.from().to_string(), "sender@localhost".to_string());
assert_eq!(
email.to(),
email.envelope().from().unwrap().to_string(),
"sender@localhost".to_string()
);
assert_eq!(
email.envelope().to(),
vec![
EmailAddress::new("user@localhost".to_string()),
EmailAddress::new("cc@localhost".to_string()),
EmailAddress::new("bcc@localhost".to_string()),
]
EmailAddress::new("user@localhost".to_string()).unwrap(),
EmailAddress::new("cc@localhost".to_string()).unwrap(),
EmailAddress::new("bcc@localhost".to_string()).unwrap(),
].as_slice()
);
}

View File

@@ -16,17 +16,17 @@ extern crate lettre;
use std::env::temp_dir;
use lettre::file::FileEmailTransport;
use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
use lettre::{SimpleSendableEmail, EmailTransport};
fn main() {
// Write to the local temp directory
let mut sender = FileEmailTransport::new(temp_dir());
let email = SimpleSendableEmail::new(
EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"user@localhost".to_string(),
&["root@localhost".to_string()],
"message_id".to_string(),
"Hello world".to_string(),
);
).unwrap();
let result = sender.send(&email);
assert!(result.is_ok());

View File

@@ -12,15 +12,15 @@ The sendmail transport sends the email using the local sendmail command.
extern crate lettre;
use lettre::sendmail::SendmailTransport;
use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
use lettre::{SimpleSendableEmail, EmailTransport};
fn main() {
let email = SimpleSendableEmail::new(
EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"user@localhost".to_string(),
&["root@localhost".to_string()],
"message_id".to_string(),
"Hello world".to_string(),
);
).unwrap();
let mut sender = SendmailTransport::new();
let result = sender.send(&email);

View File

@@ -26,15 +26,15 @@ This is the most basic example of usage:
```rust,no_run
extern crate lettre;
use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};
use lettre::{SimpleSendableEmail, EmailTransport, SmtpTransport};
fn main() {
let email = SimpleSendableEmail::new(
EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"user@localhost".to_string(),
&["root@localhost".to_string()],
"message_id".to_string(),
"Hello world".to_string(),
);
).unwrap();
// Open a local connection on port 25
let mut mailer =
@@ -52,17 +52,17 @@ fn main() {
extern crate lettre;
use lettre::smtp::authentication::{Credentials, Mechanism};
use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress, SmtpTransport};
use lettre::{SimpleSendableEmail, EmailTransport, SmtpTransport};
use lettre::smtp::extension::ClientId;
use lettre::smtp::ConnectionReuseParameters;
fn main() {
let email = SimpleSendableEmail::new(
EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"user@localhost".to_string(),
&["root@localhost".to_string()],
"message_id".to_string(),
"Hello world".to_string(),
);
).unwrap();
// Connect to a remote server on a custom port
let mut mailer = SmtpTransport::simple_builder("server.tld").unwrap()
@@ -109,10 +109,10 @@ fn main() {
let _ = email_client.connect(&("localhost", SMTP_PORT), None);
let _ = email_client.command(EhloCommand::new(ClientId::new("my_hostname".to_string())));
let _ = email_client.command(
MailCommand::new(Some(EmailAddress::new("user@example.com".to_string())), vec![])
MailCommand::new(Some(EmailAddress::new("user@example.com".to_string()).unwrap()), vec![])
);
let _ = email_client.command(
RcptCommand::new(EmailAddress::new("user@example.org".to_string()), vec![])
RcptCommand::new(EmailAddress::new("user@example.org".to_string()).unwrap(), vec![])
);
let _ = email_client.command(DataCommand);
let _ = email_client.message(Box::new("Test email".as_bytes()));

View File

@@ -13,15 +13,15 @@ testing purposes.
extern crate lettre;
use lettre::stub::StubEmailTransport;
use lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
use lettre::{SimpleSendableEmail, EmailTransport};
fn main() {
let email = SimpleSendableEmail::new(
EmailAddress::new("user@localhost".to_string()),
vec![EmailAddress::new("root@localhost".to_string())],
"user@localhost".to_string(),
&["root@localhost".to_string()],
"message_id".to_string(),
"Hello world".to_string(),
);
).unwrap();
let mut sender = StubEmailTransport::new_positive();
let result = sender.send(&email);