Dancer-Plugin-Email-1.0400000755001750001750 012503722707 15147 5ustar00naveednaveed000000000000README100644001750001750 1536212503722707 16137 0ustar00naveednaveed000000000000Dancer-Plugin-Email-1.0400NAME Dancer::Plugin::Email - Simple email sending for Dancer applications VERSION version 1.0400 SYNOPSIS use Dancer; use Dancer::Plugin::Email; post '/contact' => sub { email { from => 'bob@foo.com', to => 'sue@foo.com', subject => 'allo', body => 'Dear Sue, ...', attach => '/path/to/attachment', }; }; 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 email() will just do the right thing. IMPORTANT: 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 . FUNCTIONS This module by default exports the single function email. 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 "CONFIGURATION". 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 email with try/catch is recommended. use Dancer; use Dancer::Plugin::Email; use Try::Tiny; post '/contact' => sub { try { email { sender => 'bounces-here@foo.com', # optional from => 'bob@foo.com', to => 'sue@foo.com, jane@foo.com', bcc => 'sam@foo.com', subject => 'allo', body => 'Dear Sue, ...', multipart => 'related', # optional, see below attach => [ '/path/to/attachment1', '/path/to/attachment2', { Path => "/path/to/attachment3", # Path is required when passing a hashref. # See Mime::Entity for other optional values. Id => "blabla", } ], type => 'html', # can be 'html' or 'plain' # Optional extra headers headers => { "X-Mailer" => 'This fine Dancer application', "X-Accept-Language" => 'en', } }; } catch { error "Could not send email: $_"; }; }; 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 SMTP 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 SMTP transport are documented here "ATTRIBUTES" in Email::Sender::Transport::SMTP. You may also provide default headers in the configuration: plugins: Email: # Set default headers (OPTIONAL) headers: sender: 'bounces-here@foo.com' from: 'bob@foo.com' subject: 'default subject' X-Mailer: 'MyDancer 1.0' X-Accept-Language: 'en' # Explicity set a transport (OPTIONAL) transport: Sendmail: sendmail: '/usr/sbin/sendmail' Example configuration for sending mail via Gmail: plugins: Email: transport: SMTP: ssl: 1 host: 'smtp.gmail.com' port: 465 sasl_username: 'bob@gmail.com' sasl_password: 'secret' Use the Sendmail transport using the sendmail program in the system path: plugins: Email: transport: Sendmail: Use the Sendmail transport with an explicit path to the sendmail program: plugins: Email: transport: Sendmail: sendmail: '/usr/sbin/sendmail' Multipart messages You can embed images in HTML messages this way: first, set the type to html. Then pass the attachments as hashrefs, setting Path and Id. In the HTML body, refer to the attachment using the Id, prepending cid: in the src attribute. This works for popular webmail clients like Gmail and OE, but is not enough for Thunderbird, which wants a multipart/related mail, not the default multipart/mixed. You can fix this adding the multipart parameter set to related, which set the desired subtype when you pass attachments. Example: email { from => $from, to => $to, subject => $subject, body => q{

Image embedded:

}, type => 'html', attach => [ { Id => 'mycid', Path => '/path/to/file' }], multipart => 'related' }; The attach 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 attach method. CONTRIBUTORS * Marco Pessotto * Oleg A. Mamontov * Rusty Conover * Stefan Hornburg SEE ALSO Email::Sender MIME::Entity AUTHORS * Naveed Massjouni * Al Newkirk COPYRIGHT AND LICENSE This software is copyright (c) 2010 by awncorp. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. LICENSE100644001750001750 4363412503722707 16267 0ustar00naveednaveed000000000000Dancer-Plugin-Email-1.0400This software is copyright (c) 2010 by awncorp. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2010 by awncorp. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2010 by awncorp. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End CHANGES100644001750001750 3072512503722707 16252 0ustar00naveednaveed000000000000Dancer-Plugin-Email-1.0400================================================== Changes from 2005-03-25 00:00:00 +0000 to present. ================================================== ------------------------------------------- version 1.0400 at 2015-03-23 05:33:58 +0000 ------------------------------------------- Change: 3f879eff36bcafd741bad670db9e8c3d759b38e1 Author: Naveed Massjouni Date : 2015-03-23 01:32:49 +0000 v1.0400 Change: ff12cdb0b799bc837edfe51afa0ae30c2229c40f Author: Naveed Massjouni Date : 2015-03-18 02:54:29 +0000 Merge pull request #23 from melmothx/feature/attach-data Do not skip attachment if Data is provided Change: 010ceb54743eb7648f71a1d1be412138c0643d8c Author: Marco Pessotto Date : 2015-03-17 12:05:20 +0000 Do not skip attachment if Data is provided ------------------------------------------- version 1.0300 at 2015-01-31 08:32:39 +0000 ------------------------------------------- Change: aa55c5176d1d92aa63d74a71852250f3b4e97bc2 Author: Naveed Massjouni Date : 2015-01-31 03:32:39 +0000 v1.0300 Change: a4ac7e8fda2dd82691dbc82abacf71f22034903c Author: Naveed Massjouni Date : 2015-01-31 03:28:31 +0000 Merge pull request #21 from ironcamel/bcc added support for bcc Change: 975066ec9d5c72277ba82fc2e88065bc0abff8a5 Author: Naveed Massjouni Date : 2014-09-01 06:04:47 +0000 added support for bcc To support bcc, I followed the suggestion from: https://metacpan.org/pod/Email::Sender::Manual::QuickStart#Hey-wheres -my-Bcc-support I send 2 emails - one with the bcc header to the BCC recipients and one without the bcc header to the TO recipients. Thanks to Grega Pompe for the suggestion. ------------------------------------------- version 1.0201 at 2014-05-29 04:41:50 +0000 ------------------------------------------- Change: f2d19c7db86bcdc2ce19574bff0103b7e679954e Author: Naveed Massjouni Date : 2014-05-29 00:41:50 +0000 releasing v1.0201 ------------------------------------------- version 1.0200 at 2014-05-29 04:24:56 +0000 ------------------------------------------- Change: 7e7916e11bddb89ac799e77bc488566dbbff7308 Author: Naveed Massjouni Date : 2014-05-29 00:24:56 +0000 releasing v1.0200 Change: d8e23eef1ebceee3a73c1f59743c53f3ebac907b Author: Naveed Massjouni Date : 2014-05-17 16:32:50 +0000 Merge pull request #19 from fany/master added possibility to set sender address Change: 593067fd7a7e7b9d66b8214bd76239ac92631c21 Author: Martin H. Sluka Date : 2014-05-13 16:04:41 +0000 added possibility to set sender address (different from From header) Change: 2f799f8bf4c82257c1336e8c375b33c75443a458 Author: Naveed Massjouni Date : 2014-04-24 01:08:07 +0000 Merge pull request #18 from melmothx/feature/multipart Added "multipart" key Change: 3e2e75555b67b6512f6db69e34736130314cf38d Author: Marco Pessotto Date : 2014-04-15 10:15:08 +0000 Cleaned up and documented Change: 3ad998a6a8cf95149fdef27ae6817a2569241175 Author: Marco Pessotto Date : 2014-04-15 09:41:35 +0000 Permit the usage of make_multipart('related'); ------------------------------------------- version 1.0101 at 2014-02-09 22:38:22 +0000 ------------------------------------------- Change: bc4429f7fef86b44999f31b177586922d4be7650 Author: Naveed Massjouni Date : 2014-02-09 17:38:22 +0000 releasing v1.0101 Change: a8a84a5266cec6062cc99b1a57b4d7b0ea1996c3 Author: Naveed Massjouni Date : 2014-02-09 17:05:16 +0000 Merge pull request #17 from rustyconover/master Prevent subroutine prototype mismatch between Dancer's load and Module::Load Change: e971922f1d042f4286f05f7a1f829e8a13fe79ef Author: Rusty Conover Date : 2014-02-09 09:42:36 +0000 Change to only import debug and warning from Dancer rather than disallowing load. Change: 6be5db6d2a8530e7f1aa5145726e8cad8eae80aa Author: Rusty Conover Date : 2014-02-09 00:09:02 +0000 Prevent Dancer's load from being exported so that it doesn't conflict with Module::Load's load export. Change: 8cbeb4c5a873afe472b8b636146f13ec2a5af957 Author: Naveed Massjouni Date : 2013-10-18 07:40:22 +0000 Merge pull request #16 from episodeiv/master Provide Date header with a sensible default value Change: 24e40fddfb91adc7b61fa3a6eefa96df9d6a0bf5 Author: Dennis Lichtenthäler Date : 2013-10-18 13:54:50 +0000 Provide Date header with a sensible default value Change: 28ae884d8df76bad707b748c82a89dafbabfce03 Author: Naveed Massjouni Date : 2013-03-09 00:00:15 +0000 Getting ready to release version 1.0100 Change: 35cb9ade327c73c7d39ce291875b67c869d7461a Author: Naveed Massjouni Date : 2013-03-08 20:28:40 +0000 Merge pull request #14 from melmothx/master Make the MIME fields for attachments accessible from the plugin Change: 6d397e90e49a18fe06c1bfa66d8444d3d5767b36 Author: Marco Pessotto Date : 2013-02-27 17:08:51 +0000 untabified the file Change: ea8e9b2ae95ce3cb7bc17c31d801b25334f0ebc6 Author: Marco Pessotto Date : 2013-02-09 13:15:59 +0000 Give access to MIME fields to the user for the attachments This patch doesn't break retrocompatibility. When passing an hashref to the attachment, pass the hash to MIME::Entity, complaining if Path is missing. If a string is passed, the original routine is used. The example in the documentation has been changed to show a possible use (embedding CID images in HTML mails). ------------------------------------------- version 1.0000 at 2012-09-16 08:42:11 +0000 ------------------------------------------- Change: cd6aad8db5f7a73f65ffe7c2628b524db5d76a48 Author: Naveed Massjouni Date : 2012-09-16 08:42:11 +0000 Updating version for release 1.0000 Change: 1e66a34271e4ebdb162a158ff6922621df82b725 Author: Naveed Massjouni Date : 2012-09-16 08:17:37 +0000 Added support for type => 'html' and extra headers. Change: ab3abc1e4bbcc724d40180e523a3f3ea40490f9d Author: Naveed Massjouni Date : 2012-08-17 05:17:34 +0000 minor cleanup Change: 1cad6a9b9136cf72d2456bc76d16b1f2f9ed2d18 Author: Stefan Hornburg (Racke) Date : 2012-07-29 13:51:28 +0000 Add support for redirecting emails in development environments with Email::Sender::Transport::Redirect. Change: d5c10a5e09abcd268343bca76566e58d5e06f0f4 Author: Naveed Massjouni Date : 2012-07-22 04:39:13 +0000 Added support for file attachments Change: 160d760a9fcae1d5220c30c8aba259dc2fd6390b Author: Naveed Massjouni Date : 2012-07-16 02:36:32 +0000 Major refactor which uses Email::Sender instead of Email::Stuff Email::Stuff is built on Email::Send which is deprecated in favor of Email::Sender. This is a major refactor which basically re-implements the entire module on top of Email::Sender. This is a breaking change. I tried my best to keep the interface the same (email { ... }), but the configuration has changed drastically. Change: e1d6fe5171e3d6f2c10ddbc9c6f6960c1572cfb8 Author: Naveed Massjouni Date : 2012-07-15 13:39:03 +0000 Merge pull request #8 from racke/pr/typos Fix usage of return value in "Handle Email Failures" code recipe. Change: c4b66a07a1b5256bc5d1c82c53d2a706b62121d5 Author: Stefan Hornburg (Racke) Date : 2012-07-15 11:59:53 +0000 Fix usage of return value in "Handle Email Failures" code recipe. ------------------------------------------- version 0.1300 at 2011-06-27 06:00:04 +0000 ------------------------------------------- Change: 9bf17cab2647c9247a9c0619e045469831f0a394 Author: Naveed Massjouni Date : 2011-06-27 02:00:04 +0000 Changing Prereq -> Prereqs in dist.ini. Change: b6b2157bf88e0da5895253734b5d9bb323b9f493 Author: Naveed Massjouni Date : 2011-06-27 01:34:15 +0000 Merge branch 'master' of github.com:ironcamel/Dancer-Plugin-Email Change: 69b47cb8f9734764b2f71190fc47507d9ad005e3 Author: Naveed Massjouni Date : 2011-06-27 01:33:37 +0000 Updating version to 0.1300 for a new CPAN release. Change: 0957bb4921f7127b50c6b63a6c16717f302008c6 Author: Naveed Massjouni Date : 2011-06-26 22:18:06 +0000 Merge pull request #4 from lonerr/master Support for Content-Transfer-Encoding header. Thanks lonerr. Change: 3484301d65a4111e679d1e94d785365aec4631d1 Author: Oleg A. Mamontov Date : 2011-06-20 12:56:43 +0000 Some examples added to pod. Change: 4d46aceb30468840949303f7ceb9f572625eb702 Author: Oleg A. Mamontov Date : 2011-06-20 12:55:07 +0000 Accepts 'encoding' parameter to set appropriate Content-Transfer-Encoding header. ------------------------------------------- version 0.1203 at 2011-06-02 06:13:55 +0000 ------------------------------------------- Change: 9dd73e91b50586a9c3aedc981ea21cda01e5457a Author: Naveed Massjouni Date : 2011-06-02 02:13:55 +0000 Updating version to 0.1203 Change: 201376336d18aa55151ea015fbcf0e0f606228d0 Author: Naveed Massjouni Date : 2011-06-02 01:56:18 +0000 Fixing attachments. Thanks rrb3942. Closes #2. ------------------------------------------- version 0.1202 at 2010-12-11 11:13:32 +0000 ------------------------------------------- Change: 7894a4372ebd56577e19567a9b4702958c4bea5b Author: Naveed Massjouni Date : 2010-12-11 06:13:32 +0000 Fix for RT ticket #63706: reply_to not working. Thanks to jda@tapodi.net. Fixed warnings about uninitialized value in comparison. Updating version for a new release. Change: 34c461337cad2ed805f522d1c60c812cbb1fcb38 Author: unknown Date : 2010-10-17 15:01:53 +0000 Merge branch 'master' of git://github.com/alnewkirk/Dancer-Plugin-Email Change: 6bba359a3133f4f695e5f9a73b29878b2e66415f Author: unknown Date : 2010-10-17 14:52:49 +0000 fixed dist.ini and pod, new version Change: 0fc0d67b9d627db3dc2e3a73f3886d799df629cd Author: Al Newkirk Date : 2010-10-03 19:32:09 +0000 fixed settings precedence Change: 6e79bd0445e1941a5b67f603bf5bd4f530646f8d Author: unknown Date : 2010-10-02 15:01:48 +0000 Merge branch 'master' of git://github.com/alnewkirk/Dancer-Plugin-Email Change: 938192e9250af6a189259605da08b731aed7348d Author: unknown Date : 2010-10-02 14:58:05 +0000 added multi-type email sending support, thanks Igor Bujna Change: 6e665b8aedcd4bfaa91b65e4196d1975033deff0 Author: Al Newkirk & Associates Date : 2010-09-13 11:03:41 +0000 ran spellcheck Change: 3f45f0cb7c032b87856cad8a2d86753b084e91b0 Author: unknown Date : 2010-09-11 19:50:17 +0000 fixed typo Change: 7fa0b840d229733346251ce622925e62edda898c Author: unknown Date : 2010-09-10 20:22:09 +0000 fixed ignore Change: c0332a9cc1945c41f12e999c734558f4fe94f58d Author: unknown Date : 2010-09-10 20:20:33 +0000 fixed smtp authentication support, added reply_to, default content-type is text Change: d135fa031b9010e21bf568d58a5c1ef8e3893361 Author: Al Newkirk & Associates Date : 2010-09-10 15:43:26 +0000 working on SMTP authentication problem Change: bade4a71a267c1739360ac2c39465361b3cd0f4f Author: Al Newkirk Date : 2010-05-16 22:01:35 +0000 fixed dist.ini ----------------------------------------- version 0.01 at 2010-05-17 01:45:39 +0000 ----------------------------------------- Change: fb8217371bb639cd92daf6bb23d8ac7b9dff356d Author: Al Newkirk Date : 2010-05-16 21:45:39 +0000 initial commit, initial version ================ End of releases. ================ META.yml100644001750001750 164212503722707 16504 0ustar00naveednaveed000000000000Dancer-Plugin-Email-1.0400--- abstract: 'Simple email sending for Dancer applications' author: - 'Naveed Massjouni ' - 'Al Newkirk ' build_requires: File::Spec: 0 IO::Handle: 0 IPC::Open3: 0 Test::More: 0 perl: 5.006 strict: 0 warnings: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 0 generated_by: 'Dist::Zilla version 5.031, CPAN::Meta::Converter version 2.142690' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Dancer-Plugin-Email requires: Authen::SASL: 2.16 Dancer: 0 Dancer::Plugin: 0 Email::Date::Format: 0 Email::Sender::Simple: 0 File::Type: 0 MIME::Base64: 3.14 MIME::Entity: 0 Module::Load: 0 Net::SMTP::SSL: 1.01 Net::SSLeay: 1.58 resources: bugtracker: http://github.com/ironcamel/Dancer-Plugin-Email/issues repository: git://github.com/ironcamel/Dancer-Plugin-Email.git version: 1.0400 MANIFEST100644001750001750 27112503722707 16341 0ustar00naveednaveed000000000000Dancer-Plugin-Email-1.0400# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.031. CHANGES LICENSE MANIFEST META.yml Makefile.PL README dist.ini lib/Dancer/Plugin/Email.pm t/00-compile.t dist.ini100644001750001750 170012503722707 16672 0ustar00naveednaveed000000000000Dancer-Plugin-Email-1.0400name = Dancer-Plugin-Email author = Naveed Massjouni author = Al Newkirk version = 1.0400 license = Perl_5 copyright_holder = awncorp copyright_year = 2010 [@Filter] -bundle = @Basic -remove = Readme -remove = GatherDir [AutoPrereqs] [ChangelogFromGit] max_age = 3650 [CopyFilesFromBuild] copy = Makefile.PL [GatherDir] exclude_filename = Makefile.PL [MetaResources] bugtracker.web = http://github.com/ironcamel/Dancer-Plugin-Email/issues bugtracker.mailto = naveedm9@gmail.com repository.url = git://github.com/ironcamel/Dancer-Plugin-Email.git repository.web = http://github.com/ironcamel/Dancer-Plugin-Email repository.type = git [OurPkgVersion] [PodWeaver] [Prereqs] Authen::SASL = 2.16 Net::SMTP::SSL = 1.01 Net::SSLeay = 1.58 MIME::Base64 = 3.14 [ReadmeAnyFromPod] [ReadmeAnyFromPod / MarkdownInRoot] filename = README.md [Test::Compile] Makefile.PL100644001750001750 356112503722707 17207 0ustar00naveednaveed000000000000Dancer-Plugin-Email-1.0400 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.031. use strict; use warnings; use 5.006; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Simple email sending for Dancer applications", "AUTHOR" => "Naveed Massjouni , Al Newkirk ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Dancer-Plugin-Email", "EXE_FILES" => [], "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.006", "NAME" => "Dancer::Plugin::Email", "PREREQ_PM" => { "Authen::SASL" => "2.16", "Dancer" => 0, "Dancer::Plugin" => 0, "Email::Date::Format" => 0, "Email::Sender::Simple" => 0, "File::Type" => 0, "MIME::Base64" => "3.14", "MIME::Entity" => 0, "Module::Load" => 0, "Net::SMTP::SSL" => "1.01", "Net::SSLeay" => "1.58" }, "TEST_REQUIRES" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => 0, "strict" => 0, "warnings" => 0 }, "VERSION" => "1.0400", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Authen::SASL" => "2.16", "Dancer" => 0, "Dancer::Plugin" => 0, "Email::Date::Format" => 0, "Email::Sender::Simple" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "File::Type" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "MIME::Base64" => "3.14", "MIME::Entity" => 0, "Module::Load" => 0, "Net::SMTP::SSL" => "1.01", "Net::SSLeay" => "1.58", "Test::More" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); t000755001750001750 012503722707 15333 5ustar00naveednaveed000000000000Dancer-Plugin-Email-1.040000-compile.t100644001750001750 212712503722707 17527 0ustar00naveednaveed000000000000Dancer-Plugin-Email-1.0400/tuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.051 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Dancer/Plugin/Email.pm' ); # no fake home requested my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; Plugin000755001750001750 012503722707 20270 5ustar00naveednaveed000000000000Dancer-Plugin-Email-1.0400/lib/DancerEmail.pm100644001750001750 2372312503722707 22044 0ustar00naveednaveed000000000000Dancer-Plugin-Email-1.0400/lib/Dancer/Pluginpackage Dancer::Plugin::Email; our $VERSION = '1.0400'; # VERSION use Dancer qw(:syntax debug warning); use Dancer::Plugin; use Email::Sender::Simple 'sendmail'; use Email::Date::Format 'email_date'; use File::Type; use MIME::Entity; use Module::Load 'load'; register email => sub { my $params = shift || {}; my $multipart = delete $params->{multipart}; my $extra_headers = delete($params->{headers}) || {}; my $conf = plugin_setting; my $conf_headers = $conf->{headers} || {}; my %headers = ( %$conf_headers, %$params, %$extra_headers ); my $attach = $headers{attach}; my $sender = delete $headers{sender}; if (my $type = $headers{type}) { $headers{Type} = $type eq 'html' ? 'text/html' : 'text/plain'; } $headers{Type} ||= 'text/plain'; $headers{Format} ||= 'flowed' if $headers{Type} eq 'text/plain'; $headers{Date} ||= email_date(); delete $headers{$_} for qw(body message attach type); my $email = MIME::Entity->build( Charset => 'utf-8', Encoding => 'quoted-printable', %headers, Data => $params->{body} || $params->{message}, ); if ($attach) { if ($multipart) { # by default, when you add an attachment, # C will be called by MIME::Entity, but # defaults to 'mixed'. Thunderbird doesn't like this for # embedded images, so we have a chance to set it to # 'related' or anything that the user wants $email->make_multipart($multipart); } my @attachments = ref($attach) eq 'ARRAY' ? @$attach : $attach; for my $attachment (@attachments) { my %mime; if (ref($attachment) eq 'HASH') { %mime = %$attachment; unless ($mime{Path} || $mime{Data}) { warning "No Path or Data provided for this attachment!"; next; }; if ($mime{Path}) { $mime{Encoding} ||= 'base64'; $mime{Type} ||= File::Type->mime_type($mime{Path}); } } else { %mime = ( Path => $attachment, Type => File::Type->mime_type($attachment), Encoding => 'base64', ); } $email->attach(%mime); } } my $transport; my $conf_transport = $conf->{transport} || {}; if (my ($transport_name) = keys %$conf_transport) { my $transport_params = $conf_transport->{$transport_name} || {}; my $transport_class = "Email::Sender::Transport::$transport_name"; my $transport_redirect = $transport_params->{redirect_address}; load $transport_class; $transport = $transport_class->new($transport_params); if ($transport_redirect) { $transport_class = 'Email::Sender::Transport::Redirect'; load $transport_class; debug "Redirecting email to $transport_redirect."; $transport = $transport_class->new( transport => $transport, redirect_address => $transport_redirect ); } } my %sendmail_arg = ( transport => $transport ); $sendmail_arg{from} = $sender if defined $sender; if ( $headers{bcc} ) { sendmail $email, { %sendmail_arg, to => $headers{bcc} }; $email->head->delete('bcc'); } return sendmail $email, \%sendmail_arg; }; register_plugin; # ABSTRACT: Simple email sending for Dancer applications 1; __END__ =pod =encoding UTF-8 =head1 NAME Dancer::Plugin::Email - Simple email sending for Dancer applications =head1 VERSION version 1.0400 =head1 SYNOPSIS use Dancer; use Dancer::Plugin::Email; post '/contact' => sub { email { from => 'bob@foo.com', to => 'sue@foo.com', subject => 'allo', body => 'Dear Sue, ...', attach => '/path/to/attachment', }; }; =head1 DESCRIPTION This plugin tries to make sending emails from L applications as simple as possible. It uses L 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 C will just do the right thing. IMPORTANT: 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 L. =head1 FUNCTIONS This module by default exports the single function C. =head2 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. 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 C with try/catch is recommended. use Dancer; use Dancer::Plugin::Email; use Try::Tiny; post '/contact' => sub { try { email { sender => 'bounces-here@foo.com', # optional from => 'bob@foo.com', to => 'sue@foo.com, jane@foo.com', bcc => 'sam@foo.com', subject => 'allo', body => 'Dear Sue, ...', multipart => 'related', # optional, see below attach => [ '/path/to/attachment1', '/path/to/attachment2', { Path => "/path/to/attachment3", # Path is required when passing a hashref. # See Mime::Entity for other optional values. Id => "blabla", } ], type => 'html', # can be 'html' or 'plain' # Optional extra headers headers => { "X-Mailer" => 'This fine Dancer application', "X-Accept-Language" => 'en', } }; } catch { error "Could not send email: $_"; }; }; =head1 CONFIGURATION No configuration is necessarily required. L 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 SMTP 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 SMTP transport are documented here L. You may also provide default headers in the configuration: plugins: Email: # Set default headers (OPTIONAL) headers: sender: 'bounces-here@foo.com' from: 'bob@foo.com' subject: 'default subject' X-Mailer: 'MyDancer 1.0' X-Accept-Language: 'en' # Explicity set a transport (OPTIONAL) transport: Sendmail: sendmail: '/usr/sbin/sendmail' Example configuration for sending mail via Gmail: plugins: Email: transport: SMTP: ssl: 1 host: 'smtp.gmail.com' port: 465 sasl_username: 'bob@gmail.com' sasl_password: 'secret' Use the Sendmail transport using the sendmail program in the system path: plugins: Email: transport: Sendmail: Use the Sendmail transport with an explicit path to the sendmail program: plugins: Email: transport: Sendmail: sendmail: '/usr/sbin/sendmail' =head2 Multipart messages You can embed images in HTML messages this way: first, set the C to C. Then pass the attachments as hashrefs, setting C and C. In the HTML body, refer to the attachment using the C, prepending C in the C attribute. This works for popular webmail clients like Gmail and OE, but is not enough for Thunderbird, which wants a C mail, not the default C. You can fix this adding the C parameter set to C, which set the desired subtype when you pass attachments. Example: email { from => $from, to => $to, subject => $subject, body => q{

Image embedded:

}, type => 'html', attach => [ { Id => 'mycid', Path => '/path/to/file' }], multipart => 'related' }; The C 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 L's C method. =head1 CONTRIBUTORS =over =item * Marco Pessotto =item * Oleg A. Mamontov =item * Rusty Conover =item * Stefan Hornburg =back =head1 SEE ALSO =over =item L =item L =back =head1 AUTHORS =over 4 =item * Naveed Massjouni =item * Al Newkirk =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by awncorp. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut