I hope it's OK to revive this thread. I'm getting the same error message, after switching hosts all my scripts broke. Changing hosts also involved changing from dedicated IP to shared. Which may be relevant because the host service puts a perl path in the environment which points to a folder with a file called ReadOnly.pm, which at a glance seems to restrict changing values in the stack for objects like scalars and arrays in the installed CPAN modules. I'm testing Mail::Sender with a commandline script. I know the smtp settings work because I'm able to send a simple message using Net::SMTP::SSL but the same settings always time out When I run with perl debug flag and check the value of my hash it all looks ok.


Here's the contents of the $self hash from perl5/lib/perl5/Mail/Sender.pm: line 1022):
1022: return $self; DB<15> x $self + 0 Mail::Sender=HASH(0x2b06c40) 'authid' => 'webmaster@mydomain.org' 'authpwd' => 'thepassword' 'boundary' => 'Message-Boundary-by-Mail-Sender-1377721215' 'client' => 'hostnnn.hostmonster.com' 'debug' => 1 'from' => 'webmaster@mydomain.org' 'fromaddr' => 'webmaster@mydomain.org' 'keepconnection' => 1 'multipart' => 'mixed' 'on_errors' => 'code' 'port' => 465 'proto' => 6 'reply' => 'info@mydomain.org' 'replyaddr' => 'info@mydomain.org' 'smtp' => 'mail.mydomain.org' 'smtpaddr' => 'J?&#1009;' 'tls_allowed' => 1

And here's the $self hash from right before the call to $self->Connect(); on line 1322, I'm a little unsure about smtpaddr value. Using localhost gives me something that looks like a local ip address that's been packed. When it calls $self->Connect(); the script times out.

1322: my $s = $self->{'socket'} || $self->Connect(); DB<3> x $self + 0 Mail::Sender=HASH(0x237e5f0) '_had_newline' => 1 'authid' => 'webmaster@mydomain.org' 'authpwd' => 'therightpassword' 'boundary' => 'Message-Boundary-by-Mail-Sender-1377722649' 'client' => 'abcdefg.hostserver.com' 'debug' => 1 'from' => 'webmaster@mydomain.org' 'fromaddr' => 'webmaster@mydomain.org' 'keepconnection' => 1 'multipart' => 0 'on_errors' => 'code' 'port' => 465 'proto' => 6 'reply' => 'info@mydomain.org' 'replyaddr' => 'info@mydomain.org' 'smtp' => 'mail.mydomain.org' 'smtpaddr' => 'J?&#1009;' 'subject' => 'smtp-ssl-auth test with Mail Sender module' 'tls_allowed' => 1 'to' => 'devmail@mydomain.org' 'to_list' => ARRAY(0x1eecbe0) 0 'devmail@mydomain.org'

And here's the code I'm using;
#!/usr/bin/perl use strict; use warnings; use Mail::Sender; ## use Carp (); ## local $SIG{__WARN__} = \&Carp::cluck; BEGIN { my $b__dir = (-d '/home2/avantclo/perl'?'/home2/avantclo/perl':( getpw +uid($>) )[7].'/perl'); unshift @INC,$b__dir.'5/lib/perl5',$b__dir.'5/lib/perl5/x86_64-linux-t +hread-multi',map { $b__dir . $_ } @INC;} my $user = 'webmaster@mydomain.org'; my $pass = 'TheRightPassword'; my $mlserver='mail.mydomain.org'; my $replyaddey='info@mydomain.org'; my $smtpaddey= 'localhost'; my $to='devmail@mydomain.org'; my $from_name='Webmaster'; my $from_email='webmaster@mydomain.org'; my $subject='smtp-ssl-auth test with Mail Sender module'; my $html="<html><body>Test HTML content</body></html>"; my $debugon = 1; my $debugoff = 0; my $portnum = 465; my $errorset = "code"; my $keepconn = 1; my $tlsreq = 1; $Mail::Sender::NO_X_MAILER = 1; open my $DEBUG, ">> ../../test/testsender1debugfile.txt" or die "Can't open the debug file: $!\n"; my $smtps = Mail::Sender->new({ smtp=>($mlserver), port=>($portnum), authid=>($user), authpwd=>($pass), from=>($from_email), reply=>($replyaddey), debug=>($debugon), on_errors => ($errorset), keepconnection=>($keepconn), TLS_allowed=>($tlsreq)}); $smtps->Open({ to=>($to), from=>($from_email), subject=>($subject)}); defined (ref $smtps) or die "Failed to open the message: $smtps->{ +'error_msg'}\n"; $smtps->SendLineEnc($html); $smtps->SendLineEnc("This will be the body of the message.\n") +; $smtps->SendLineEnc("\n--\nVery Official Looking .sig here\n") +; if ($Mail::Sender::Error eq '') { print "Test message has been sent\n"; } else { die "Failed to send the message: $smtps->{'error_msg'}\n"; } $smtps->Close();

In reply to Re: connection not established. error in Mail::Sender by BrianDSy
in thread connection not established. error in Mail::Sender by ungalnanban

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.