Acme-CPANModulesBundle-Import-PerlDancerAdvent-2018

 view release on metacpan or  search on metacpan

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


<h2><a name="inline_images"></a>Inline images</h2>

<p>You can simply deliver emails with links to images, but usually email clients would not load them without user interaction.
It is possible though to attached the images to the email and reference them in the email body with a custom HTML tag:</p>
<pre class="prettyprint">    email {
        from      =&gt; 'foo@perl.dance',
        to        =&gt; 'bar@perl.dance',
        subject   =&gt; 'Welcome to the dancefloor!',
        body      =&gt; q{&lt;p&gt;Image embedded: &lt;img src="cid:mycid"/&gt;&lt;/p&gt;},
        type      =&gt; 'html',
        attach    =&gt; [ { Id =&gt; 'mycid', Path =&gt; '/dancefloor/dcr-header-logo.png' }],
        multipart =&gt; 'related'
};</pre>

<h2><a name="providing_plain_text_part"></a>Providing plain text part</h2>

<p><a href="https://metacpan.org/pod/HTML::FormatText::WithLinks">HTML::FormatText::WithLinks</a> makes it easy to provide a plain text version
of your HTML email:</p>
<pre class="prettyprint">my $html = template $template, $tokens, { layout =&gt; 'email' };

my $f    = HTML::FormatText::WithLinks-&gt;new;
my $text = $f-&gt;parse($html);

email {
    from =&gt; 'foo@perl.dance',
    to =&gt; 'bar@perl.dance',
    subject =&gt; 'Welcome to the dancefloor!',
    body   =&gt; $text,
    attach =&gt; {
        Data     =&gt; $html,
        Type     =&gt; "text/html"
    },
    multipart =&gt; 'alternative',
};</pre>

<h2><a name="configuration"></a>Configuration</h2>

<h3><a name="transports"></a>Transports</h3>

<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>
<pre class="prettyprint">X-Intercepted-To: "Bar" &lt;bar@perl.dance&gt;
X-Intercepted-Cc: "Baz" &lt;baz@perl.dance&gt;</pre>

<p>Note: it's the presence of the <code>redirect_address</code> parameter which tells the
plugin you want mails redirected to that address, this will work with whatever
transport you wish to use.</p>
<h3><a name="preseed_headers"></a>Preseed headers</h3>

<p>If you have a standard email address and/or you want to have extra email headers, you can specify these in the
configuration as well:</p>
<pre class="prettyprint">plugins:
  Email:
    sender: "2019@perl.dance"
    from: "Perl Dancer Conference 2019 &lt;2019@perl.dance&gt;"
    X-Mailer: "PerlDance2018 4.0"</pre>

<h2><a name="author"></a>Author</h2>

<p>This article has been written by racke for the Perl Dancer 
Advent Calendar 2018.</p>
</div>

 <div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'danceradvent'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>




</div>



<div id="footer">
Powered by the  
<a href="http://perldancer.org/" title="Perl Dancer - Perl web framework">
Dancer Perl web framework</a>
</div>
</div>


<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25174467-2']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';



( run in 0.810 second using v1.01-cache-2.11-cpan-39bf76dae61 )