Acme-CPANModulesBundle-Import-PerlDancerAdvent-2018

 view release on metacpan or  search on metacpan

devdata/http_advent.perldancer.org_2018_17  view on Meta::CPAN

        <li><a class="feed" href="/feed/2018">RSS</a></li>
    </ul>
</li>
</ul>
</div>


<div id="content">
<div class="pod-document"><h1><a name="dancer_and_email"></a>Dancer and Email</h1>

<p>Web applications regularly need to send email to its users, e.g. receipts or password reset links. 
The <a href="https://metacpan.org/pod/Dancer2::Plugin::Email">Email</a> plugin for Dancer2 simplifies this task by
providing the <code>email</code> keyword and a sane default configuration.</p>
<p>So the unavoidable "Hello world" example would look like:</p>
<pre class="prettyprint">email {
    from =&gt; 'foo@perl.dance',
    to =&gt; 'bar@perl.dance',
    subject =&gt; 'Hello world',
    text =&gt; 'Welcome to the dancefloor!',
};</pre>

devdata/http_advent.perldancer.org_2018_17  view on Meta::CPAN

<p>Under the hood the plugin uses <a href="https://metacpan.org/pod/Email::Sender">Email::Sender</a>, so you can utilize its transports instead of the "sendmail" one (local mail server).</p>
<p>This is just a matter of adjusting your configuration:</p>
<pre class="prettyprint">plugins:
  Email:
    transport:
      SMTP:
        ssl: 1
        host: 'mail.perl.dance'
        port: 465
        sasl_username: 'foo@perl.dance'
        sasl_password: 'nevairbe'</pre>

<p>In development you want to <b>prevent</b> email going out to <b>real users</b>.</p>
<p>This can be done with the <a href="https://metacpan.org/pod/Email::Sender::Transport::Redirect">Redirect</a> transport:</p>
<pre class="prettyprint">plugins:
  Email:
    transport:
      Sendmail:
        redirect_address: racke@perl.dance</pre>

<p>All email will be send to the specificied address, but with extra headers added with the original recipients:</p>



( run in 0.470 second using v1.01-cache-2.11-cpan-49f99fa48dc )