adrenalin
adrenalin

Reputation: 135

Perl smtp email send is not working

I'm trying to send emails from my gmail account, and get the error:

Error sending email: Connect failed :IO::Socket::INET: connect: timeout at /home/tas/perl5/lib/perl5/Email/Send/SMTP/TLS.pm line 45

I've tried several different email adresses (gmail and others) but the result is the same.

I use this code:

#!/usr/bin/perlml
use Email::Send;
print "Content-type: text/html\n\n";
my $mailer = Email::Send->new( {
    mailer => 'SMTP::TLS',
    mailer_args => [
        Host => 'smtp.gmail.com',
        Port => 587,
        User => '[email protected]',
        Password => 'XXXXXXXXX',
        Hello => 'fayland.org',
    ]
} );

use Email::Simple::Creator; # or other Email::
my $email = Email::Simple->create(
    header => [
        From    => '[email protected]',
        To      => '[email protected]',
        Subject => 'test',
    ],
    body => 'test',
);
eval { $mailer->send($email) };
die "Error sending email: $@" if $@;

What is wrong here? Any other ways to send emails using smtp?

Upvotes: 1

Views: 529

Answers (1)

Dave Cross
Dave Cross

Reputation: 69314

Error sending email: Connect failed :IO::Socket::INET: connect: timeout at /home/tas/perl5/lib/perl5/Email/Send/SMTP/TLS.pm line 45

Looks like there is nothing wrong with your Perl code. It looks like this is a networking problem. Something in your network is preventing you from connecting to Gmail on port 587.

You probably need to discuss this with the system support people for your server.

Upvotes: 4

Related Questions