Giter Club home page Giter Club logo

p5-mojo-smtp-client's People

Contributors

karel-m avatar maxhq avatar olegwtf avatar s1037989 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

p5-mojo-smtp-client's Issues

Fix compatibility with latest Mojo::IOLoop::Delay

Plan:

  • Put only steps for current command into delay object
  • Store steps from send() inside array variable, from where we can get the next command to costruct steps for delay object
  • prepend_cmd will prepend to this array variable
  • Delay object may be cleaned with steps() without arguments
  • Use then() from promises instead of finish event

DATA & lines starting with . (dot)

send() method does not correctly handle a situation when data contains a line starting with . (dot).

According to: http://tools.ietf.org/html/rfc5321#section-4.5.2

Before sending a line of mail text, the SMTP client checks the
first character of the line.  If it is a period, one additional
period is inserted at the beginning of the line.

The current way of handling data value might be a feature. In that case I propose adding named argument data_esc which will handle the above mentioned escaping.

Here is a demonstration - in both cases the second line is missing the dot at the beginning. It also demonstrates that it cannot be "solved" by feeding data with a string created by MIME::Lite->new(..)->as_string. IMHO this escaping should happen in Mojo::SMTP::Client.

warn "A=" . $smtp->send(
        from => '[email protected]',
        to   => '[email protected]',
        data => join("\r\n", 'From: [email protected]',
                             'To: [email protected]',
                             'Subject: Dot test A',
                             '',
                             'first line',
                             '.second line starting with dot',
                             'last line',
                ),
        quit => 1
);

my $msg = MIME::Lite->new(
        From    => '[email protected]',
        To      => '[email protected]',
        Subject => 'Dot test B',
        Data    => join("\r\n", 
                             'first line',
                             '.second line starting with dot',
                             'last line',
                   ),
);

warn "B=" . $smtp->send(
        from => '[email protected]',
        to   => '[email protected]',
        data => $msg->as_string,
        quit => 1,
);

make test failed at t/02_smtp.t line 22 and others

First, thanks for offering this module!

While building a docker image with some perl modules that I needed, the build stopped with these errors:

Screen dump:

root@b698e7f89d03:/# cpanm -M http://localcpan.lan:3111 --verbose Mojo::SMTP::Client
cpanm (App::cpanminus) 1.7044 on perl 5.022000 built for x86_64-linux
Work directory is /root/.cpanm/work/1532327041.12530
You have make /usr/bin/make
You have LWP 6.33
You have /bin/tar: tar (GNU tar) 1.29
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
Searching Mojo::SMTP::Client on mirror http://localcpan.lan:3111 ...
Downloading index file http://localcpan.lan:3111/modules/02packages.details.txt.gz ...
--> Working on Mojo::SMTP::Client
Fetching http://localcpan.lan:3111/authors/id/O/OL/OLEG/Mojo-SMTP-Client-0.15.tar.gz ... OK
Unpacking Mojo-SMTP-Client-0.15.tar.gz
Mojo-SMTP-Client-0.15/
Mojo-SMTP-Client-0.15/META.yml
Mojo-SMTP-Client-0.15/Changes
Mojo-SMTP-Client-0.15/Makefile.PL
Mojo-SMTP-Client-0.15/t/
Mojo-SMTP-Client-0.15/t/cert/
Mojo-SMTP-Client-0.15/t/cert/server-key.pem
Mojo-SMTP-Client-0.15/t/cert/server-cert.pem
Mojo-SMTP-Client-0.15/t/01_load.t
Mojo-SMTP-Client-0.15/t/lib/
Mojo-SMTP-Client-0.15/t/lib/Utils.pm
Mojo-SMTP-Client-0.15/t/02_smtp.t
Mojo-SMTP-Client-0.15/t/03_smtp_nb.t
Mojo-SMTP-Client-0.15/MANIFEST
Mojo-SMTP-Client-0.15/lib/
Mojo-SMTP-Client-0.15/lib/Mojo/
Mojo-SMTP-Client-0.15/lib/Mojo/SMTP/
Mojo-SMTP-Client-0.15/lib/Mojo/SMTP/Client.pm
Mojo-SMTP-Client-0.15/lib/Mojo/SMTP/Client/
Mojo-SMTP-Client-0.15/lib/Mojo/SMTP/Client/Response.pm
Mojo-SMTP-Client-0.15/lib/Mojo/SMTP/Client/Exception.pm
Mojo-SMTP-Client-0.15/META.json
Mojo-SMTP-Client-0.15/README
Entering Mojo-SMTP-Client-0.15
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.04_01)
Running Makefile.PL
Configuring Mojo-SMTP-Client-0.15 ... Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Mojo::SMTP::Client
Writing MYMETA.yml and MYMETA.json
OK
Checking dependencies from MYMETA.json ...
Checking if you have Test::More 0.88 ... Yes (1.302133)
Checking if you have Mojolicious 7.53 ... Yes (7.88)
Building and testing Mojo-SMTP-Client-0.15 ... cp lib/Mojo/SMTP/Client.pm blib/lib/Mojo/SMTP/Client.pm
cp lib/Mojo/SMTP/Client/Response.pm blib/lib/Mojo/SMTP/Client/Response.pm
cp lib/Mojo/SMTP/Client/Exception.pm blib/lib/Mojo/SMTP/Client/Exception.pm
PERL_DL_NONLAZY=1 "/opt/perlbrew/perls/perl-5.22.0-1.001/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01_load.t ..... ok   
t/02_smtp.t ..... 1/? 
#   Failed test 'no error'
#   at t/02_smtp.t line 22.
# SSL connect attempt failed error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

#   Failed test 'right response code'
#   at t/02_smtp.t line 23.
#          got: undef
#     expected: '220'

#   Failed test 'right message'
#   at t/02_smtp.t line 24.
#          got: undef
#     expected: 'quit ok'

#   Failed test 'stringify message'
#   at t/02_smtp.t line 25.
#          got: ''
#     expected: '220 quit ok
# '

Thanks,
Michael

key too small

I see that there were some attempts made to correct this. I'm still having this issue with 0.20_2.

How are you generating new cert and key files?

What is the cause? Newer IO::Socket::SSL?

Incompatibility with Mojolicious 7.49+

There are couple of issues:

  • $delay->catch has changed
  • $delay->remaining is deprecated
  • Mojo::IOLoop::Delay's finish event is deprecated

See Changes https://metacpan.org/changes/release/SRI/Mojolicious-7.55#L25

Quick&dirty hack dealing just with catch changes:

diff --git a/lib/Mojo/SMTP/Client.pm b/lib/Mojo/SMTP/Client.pm
index 1711fec..f19c842 100644
--- a/lib/Mojo/SMTP/Client.pm
+++ b/lib/Mojo/SMTP/Client.pm
@@ -140,8 +140,9 @@ sub send {
        push @steps, $self->_make_cmd_steps(0, @_);

        # non-blocking
-       my $delay = $self->{delay} = Mojo::IOLoop::Delay->new(ioloop => $self->_ioloop)->steps(@steps)->catch(sub {
-               shift->emit(finish => $_[0]);
+       my $delay = $self->{delay} = Mojo::IOLoop::Delay->new(ioloop => $self->_ioloop)->steps(@steps);
+       $delay->catch(sub {
+               $delay->emit(finish => $_[0]);
        });
        $delay->on(finish => sub {
                if ($cb) {

However, I am afraid that the proper patch will be a bit more complicated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.