.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Dancer::Plugin::Email 3pm" .TH Dancer::Plugin::Email 3pm "2016-04-26" "perl v5.22.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Dancer::Plugin::Email \- Simple email sending for Dancer applications .SH "VERSION" .IX Header "VERSION" version 1.0400 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Dancer; \& use Dancer::Plugin::Email; \& \& post \*(Aq/contact\*(Aq => sub { \& email { \& from => \*(Aqbob@foo.com\*(Aq, \& to => \*(Aqsue@foo.com\*(Aq, \& subject => \*(Aqallo\*(Aq, \& body => \*(AqDear Sue, ...\*(Aq, \& attach => \*(Aq/path/to/attachment\*(Aq, \& }; \& }; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This plugin tries to make sending emails from Dancer applications as simple as possible. It uses Email::Sender under the hood. In a lot of cases, no configuration is required. For example, if your app is hosted on a unix-like server with sendmail installed, calling \f(CW\*(C`email()\*(C'\fR will just do the right thing. .PP \&\s-1IMPORTANT:\s0 Version 1.x of this module is not backwards compatible with the 0.x versions. This module was originally built on Email::Stuff which was built on Email::Send which has been deprecated in favor of Email::Sender. Versions 1.x and on have be refactored to use Email::Sender. I have tried to keep the interface the same as much as possible. The main difference is the configuration. If there are features missing that you were using in older versions, then please let me know by creating an issue on github . .SH "FUNCTIONS" .IX Header "FUNCTIONS" This module by default exports the single function \f(CW\*(C`email\*(C'\fR. .SS "email" .IX Subsection "email" This function sends an email. It takes a single argument, a hashref of parameters. Default values for the parameters may be provided in the headers section of the \*(L"\s-1CONFIGURATION\*(R"\s0. Paramaters provided to this function will override the corresponding configuration values if there is any overlap. An exception is thrown if sending the email fails, so wrapping calls to \f(CW\*(C`email\*(C'\fR with try/catch is recommended. .PP .Vb 3 \& use Dancer; \& use Dancer::Plugin::Email; \& use Try::Tiny; \& \& post \*(Aq/contact\*(Aq => sub { \& try { \& email { \& sender => \*(Aqbounces\-here@foo.com\*(Aq, # optional \& from => \*(Aqbob@foo.com\*(Aq, \& to => \*(Aqsue@foo.com, jane@foo.com\*(Aq, \& bcc => \*(Aqsam@foo.com\*(Aq, \& subject => \*(Aqallo\*(Aq, \& body => \*(AqDear Sue, ...\*(Aq, \& multipart => \*(Aqrelated\*(Aq, # optional, see below \& attach => [ \& \*(Aq/path/to/attachment1\*(Aq, \& \*(Aq/path/to/attachment2\*(Aq, \& { \& Path => "/path/to/attachment3", \& # Path is required when passing a hashref. \& # See Mime::Entity for other optional values. \& Id => "blabla", \& } \& ], \& type => \*(Aqhtml\*(Aq, # can be \*(Aqhtml\*(Aq or \*(Aqplain\*(Aq \& # Optional extra headers \& headers => { \& "X\-Mailer" => \*(AqThis fine Dancer application\*(Aq, \& "X\-Accept\-Language" => \*(Aqen\*(Aq, \& } \& }; \& } catch { \& error "Could not send email: $_"; \& }; \& }; .Ve .SH "CONFIGURATION" .IX Header "CONFIGURATION" No configuration is necessarily required. Email::Sender::Simple tries to make a good guess about how to send the message. It will usually try to use the sendmail program on unix-like systems and \s-1SMTP\s0 on Windows. However, you may explicitly configure a transport in your configuration. Only one transport may be configured. For documentation for the parameters of the transport, see the corresponding Email::Sender::Transport::* module. For example, the parameters available for the \s-1SMTP\s0 transport are documented here \*(L"\s-1ATTRIBUTES\*(R"\s0 in Email::Sender::Transport::SMTP. .PP You may also provide default headers in the configuration: .PP .Vb 10 \& plugins: \& Email: \& # Set default headers (OPTIONAL) \& headers: \& sender: \*(Aqbounces\-here@foo.com\*(Aq \& from: \*(Aqbob@foo.com\*(Aq \& subject: \*(Aqdefault subject\*(Aq \& X\-Mailer: \*(AqMyDancer 1.0\*(Aq \& X\-Accept\-Language: \*(Aqen\*(Aq \& # Explicity set a transport (OPTIONAL) \& transport: \& Sendmail: \& sendmail: \*(Aq/usr/sbin/sendmail\*(Aq .Ve .PP Example configuration for sending mail via Gmail: .PP .Vb 9 \& plugins: \& Email: \& transport: \& SMTP: \& ssl: 1 \& host: \*(Aqsmtp.gmail.com\*(Aq \& port: 465 \& sasl_username: \*(Aqbob@gmail.com\*(Aq \& sasl_password: \*(Aqsecret\*(Aq .Ve .PP Use the Sendmail transport using the sendmail program in the system path: .PP .Vb 4 \& plugins: \& Email: \& transport: \& Sendmail: .Ve .PP Use the Sendmail transport with an explicit path to the sendmail program: .PP .Vb 5 \& plugins: \& Email: \& transport: \& Sendmail: \& sendmail: \*(Aq/usr/sbin/sendmail\*(Aq .Ve .SS "Multipart messages" .IX Subsection "Multipart messages" You can embed images in \s-1HTML\s0 messages this way: first, set the \f(CW\*(C`type\*(C'\fR to \f(CW\*(C`html\*(C'\fR. Then pass the attachments as hashrefs, setting \f(CW\*(C`Path\*(C'\fR and \&\f(CW\*(C`Id\*(C'\fR. In the \s-1HTML\s0 body, refer to the attachment using the \f(CW\*(C`Id\*(C'\fR, prepending \f(CW\*(C`cid:\*(C'\fR in the \f(CW\*(C`src\*(C'\fR attribute. This works for popular webmail clients like Gmail and \s-1OE,\s0 but is not enough for Thunderbird, which wants a \f(CW\*(C`multipart/related\*(C'\fR mail, not the default \&\f(CW\*(C`multipart/mixed\*(C'\fR. You can fix this adding the \f(CW\*(C`multipart\*(C'\fR parameter set to \f(CW\*(C`related\*(C'\fR, which set the desired subtype when you pass attachments. .PP Example: .PP .Vb 9 \& email { \& from => $from, \& to => $to, \& subject => $subject, \& body => q{

Image embedded:

}, \& type => \*(Aqhtml\*(Aq, \& attach => [ { Id => \*(Aqmycid\*(Aq, Path => \*(Aq/path/to/file\*(Aq }], \& multipart => \*(Aqrelated\*(Aq \& }; .Ve .PP The \f(CW\*(C`attach\*(C'\fR value accepts either a single attachment or an arrayref of attachment. Each attachment may be a scalar, with the path of the file to attach, or an hashref, in which case the hashref is passed to the Mime::Entity's \f(CW\*(C`attach\*(C'\fR method. .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" .IP "\(bu" 4 Marco Pessotto .IP "\(bu" 4 Oleg A. Mamontov .IP "\(bu" 4 Rusty Conover .IP "\(bu" 4 Stefan Hornburg .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "Email::Sender" 4 .IX Item "Email::Sender" .PD 0 .IP "MIME::Entity" 4 .IX Item "MIME::Entity" .PD .SH "AUTHORS" .IX Header "AUTHORS" .IP "\(bu" 4 Naveed Massjouni .IP "\(bu" 4 Al Newkirk .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2010 by awncorp. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.