597 lines
13 KiB
HTML
597 lines
13 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en" class="js csstransforms3d">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
|
<meta name="generator" content="Hugo 0.32.4" />
|
|
<meta name="description" content="Documentation for the Lettre mailer in Rust">
|
|
<meta name="author" content="Alexis Mousset">
|
|
|
|
<link rel="shortcut icon" href="https://lettre.github.io/lettre/images/favicon.png" type="image/x-icon" />
|
|
|
|
<title>Stub transport :: Lettre site</title>
|
|
|
|
|
|
<link href="/lettre/css/nucleus.css?1516041983" rel="stylesheet">
|
|
<link href="/lettre/css/font-awesome.min.css?1516041983" rel="stylesheet">
|
|
<link href="/lettre/css/hybrid.css?1516041983" rel="stylesheet">
|
|
<link href="/lettre/css/featherlight.min.css?1516041983" rel="stylesheet">
|
|
<link href="/lettre/css/perfect-scrollbar.min.css?1516041983" rel="stylesheet">
|
|
<link href="/lettre/css/auto-complete.css?1516041983" rel="stylesheet">
|
|
<link href="/lettre/css/theme.css?1516041983" rel="stylesheet">
|
|
<link href="/lettre/css/hugo-theme.css?1516041983" rel="stylesheet">
|
|
|
|
|
|
<script src="/lettre/js/jquery-2.x.min.js?1516041983"></script>
|
|
|
|
<style type="text/css">
|
|
:root #header + #content > #left > #rlblock_left{
|
|
display:none !important;
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
<body class="" data-url="/lettre/sending-messages/stub/">
|
|
<nav id="sidebar" class="">
|
|
|
|
|
|
|
|
<div id="header-wrapper">
|
|
<div id="header">
|
|
<a href="https://lettre.github.io/lettre/getting-started/intro/"><img src="https://lettre.github.io/lettre/images/logo50.png" /></a>
|
|
|
|
</div>
|
|
|
|
<div class="searchbox">
|
|
<label for="search-by"><i class="fa fa-search"></i></label>
|
|
<input data-search-input id="search-by" type="text" placeholder="Search...">
|
|
<span data-search-clear=""><i class="fa fa-close"></i></span>
|
|
</div>
|
|
|
|
<script type="text/javascript" src="/lettre/js/lunr.min.js?1516041983"></script>
|
|
<script type="text/javascript" src="/lettre/js/auto-complete.js?1516041983"></script>
|
|
<script type="text/javascript">
|
|
|
|
var baseurl = "https:\/\/lettre.github.io\/lettre";
|
|
|
|
</script>
|
|
<script type="text/javascript" src="/lettre/js/search.js?1516041983"></script>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="highlightable">
|
|
<ul class="topics">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li data-nav-id="/lettre/getting-started/" title="Getting started" class="dd-item
|
|
|
|
|
|
|
|
">
|
|
<a href="/lettre/getting-started/">
|
|
Getting started
|
|
|
|
</a>
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li data-nav-id="/lettre/getting-started/intro/" title="Introduction" class="dd-item ">
|
|
<a href="/lettre/getting-started/intro/">
|
|
Introduction
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li data-nav-id="/lettre/creating-messages/" title="Creating messages" class="dd-item
|
|
|
|
|
|
|
|
">
|
|
<a href="/lettre/creating-messages/">
|
|
Creating messages
|
|
|
|
</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li data-nav-id="/lettre/sending-messages/" title="Sending messages" class="dd-item
|
|
parent
|
|
|
|
|
|
">
|
|
<a href="/lettre/sending-messages/">
|
|
Sending messages
|
|
|
|
</a>
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li data-nav-id="/lettre/sending-messages/intro/" title="Introduction" class="dd-item ">
|
|
<a href="/lettre/sending-messages/intro/">
|
|
Introduction
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li data-nav-id="/lettre/sending-messages/smtp/" title="SMTP transport" class="dd-item ">
|
|
<a href="/lettre/sending-messages/smtp/">
|
|
SMTP transport
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li data-nav-id="/lettre/sending-messages/sendmail/" title="Sendmail transport" class="dd-item ">
|
|
<a href="/lettre/sending-messages/sendmail/">
|
|
Sendmail transport
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li data-nav-id="/lettre/sending-messages/file/" title="File transport" class="dd-item ">
|
|
<a href="/lettre/sending-messages/file/">
|
|
File transport
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li data-nav-id="/lettre/sending-messages/stub/" title="Stub transport" class="dd-item active">
|
|
<a href="/lettre/sending-messages/stub/">
|
|
Stub transport
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
<section id="footer">
|
|
<p>Built with <a href="https://github.com/matcornic/hugo-theme-learn"><i class="fa fa-heart"></i></a> from <a href="http://getgrav.org">Grav</a> and <a href="http://gohugo.io/">Hugo</a></p>
|
|
|
|
</section>
|
|
</div>
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
|
|
<section id="body">
|
|
<div id="overlay"></div>
|
|
<div class="padding highlightable sticky-parent">
|
|
|
|
<div class="sticky-spacer">
|
|
<div id="top-bar">
|
|
|
|
|
|
|
|
|
|
<div id="top-github-link">
|
|
<a class="github-link" href="https://github.com/lettre/lettre/edit/master/website/content/sending-messages/stub.md" target="blank">
|
|
<i class="fa fa-code-fork"></i>
|
|
Edit this page
|
|
</a>
|
|
</div>
|
|
|
|
|
|
|
|
<div id="breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb">
|
|
<span id="sidebar-toggle-span">
|
|
<a href="#" id="sidebar-toggle" data-sidebar-toggle="">
|
|
<i class="fa fa-bars"></i>
|
|
</a>
|
|
</span>
|
|
|
|
<span id="toc-menu"><i class="fa fa-list-alt"></i></span>
|
|
|
|
<span class="links">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a href='/lettre/'>Lettre site</a> > <a href='/lettre/sending-messages/'>Sending messages</a> > Stub transport
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</span>
|
|
</div>
|
|
|
|
<div class="progress">
|
|
<div class="wrapper">
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div id="body-inner">
|
|
|
|
<h1>Stub transport</h1>
|
|
|
|
|
|
|
|
|
|
|
|
<p>The stub transport only logs message envelope and drops the content. It can be useful for
|
|
testing purposes.</p>
|
|
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-rust" data-lang="rust"><span style="color:#66d9ef">use</span> lettre::stub::StubEmailTransport;
|
|
<span style="color:#66d9ef">use</span> lettre::{SimpleSendableEmail, EmailTransport, EmailAddress};
|
|
|
|
<span style="color:#66d9ef">let</span> email <span style="color:#f92672">=</span> SimpleSendableEmail::new(
|
|
EmailAddress::new(<span style="color:#e6db74">"user@localhost"</span>.to_string()),
|
|
vec<span style="color:#f92672">!</span>[EmailAddress::new(<span style="color:#e6db74">"root@localhost"</span>.to_string())],
|
|
<span style="color:#e6db74">"message_id"</span>.to_string(),
|
|
<span style="color:#e6db74">"Hello world"</span>.to_string(),
|
|
);
|
|
|
|
<span style="color:#66d9ef">let</span> <span style="color:#66d9ef">mut</span> sender <span style="color:#f92672">=</span> StubEmailTransport::new_positive();
|
|
<span style="color:#66d9ef">let</span> result <span style="color:#f92672">=</span> sender.send(<span style="color:#f92672">&</span>email);
|
|
assert<span style="color:#f92672">!</span>(result.is_ok());</code></pre></div>
|
|
<p>Will log (when using a logger like <code>env_logger</code>):</p>
|
|
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-text" data-lang="text">b7c211bc-9811-45ce-8cd9-68eab575d695: from=<user@localhost> to=<root@localhost></code></pre></div>
|
|
|
|
<footer class=" footline" >
|
|
|
|
</footer>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="navigation">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a class="nav nav-prev" href="/lettre/sending-messages/file/" title="File transport"> <i class="fa fa-chevron-left"></i></a>
|
|
|
|
|
|
<a class="nav nav-next" href="/lettre/sending-messages/intro/" title="Introduction" style="margin-right: 0px;"><i class="fa fa-chevron-right"></i></a>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<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?1516041983"></script>
|
|
<script src="/lettre/js/perfect-scrollbar.min.js?1516041983"></script>
|
|
<script src="/lettre/js/perfect-scrollbar.jquery.min.js?1516041983"></script>
|
|
<script src="/lettre/js/jquery.sticky-kit.min.js?1516041983"></script>
|
|
<script src="/lettre/js/featherlight.min.js?1516041983"></script>
|
|
<script src="/lettre/js/html5shiv-printshiv.min.js?1516041983"></script>
|
|
<script src="/lettre/js/highlight.pack.js?1516041983"></script>
|
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
<script src="/lettre/js/modernizr.custom.71422.js?1516041983"></script>
|
|
<script src="/lettre/js/learn.js?1516041983"></script>
|
|
<script src="/lettre/js/hugo-learn.js?1516041983"></script>
|
|
|
|
<link href="/lettre/mermaid/mermaid.css?1516041983" type="text/css" rel="stylesheet" />
|
|
<script src="/lettre/mermaid/mermaid.js?1516041983"></script>
|
|
<script>
|
|
mermaid.initialize({ startOnLoad: true });
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html>
|
|
|