I've try to send mail using perl with attachment I've tried with Email::Stuff and MIME::Lite,during run time i got some error as Authentication failed or server not connected can anybody help me?
corresponding code is:
use MIME::Lite;
use Net::SMTP;
### Adjust sender, recipient and your SMTP mailhost
my $from_address = 'atme04#gmail.com';
my $to_address = 'thiyagu040#gmail.com';
my $mail_host = 'smtp.gmail.com';
### Adjust subject and body message
my $subject = 'A message with 2 parts ...';
my $message_body = "Here's the attachment file(s) you wanted";
my $your_file_zip = 'my.zip';
$msg = MIME::Lite->new (
From => $from_address,
To => $to_address,
Subject => $subject,
Type =>'multipart/mixed'
) or die "Error creating multipart container: $!\n";
MIME::Lite->send('smtp', 'smtp.gmail.com' ,
Port =>465 ,
Timeout=>320 ,
Debug => 1 ,
Hello => $mail_host,
User => $from_address,
Password => 'Thiyagu.04' );
#$mime_msg->send() or die "Error sending message: $!\n";
#MIME::Lite->send('smtp',$mail_host,AuthUser=> $from_address, AuthPass=>"apssword");
$msg->send();
error message is;
SMTP Failed to connect to mail server: A connection attempt failed because the connected party did not properly respond aft
er a period of time, or established connection failed because connected host has failed to respond.
at mail.pl line 54.
thanks in advance
The error message seems pretty clear to me. The problem is with your connection to the mail server - so changing the module that you're using is unlikely to achieve anything useful. I don't know enough about Gmail's server settings to comment on what the problem is, but this page has some suggestions that you might follow. Specifically, you could check that the Gmail account has 'allow authentication' turned on and that your mail client (the Perl program) is using SSL for the connection.
Also, this might be easier if you used an email that was specifically designed for use with Gmail. Email::Send::SMTP::Gmail looks tailor-made for your requirements.
Related
I am currently trying to connect to a gmail inbox using Perl and
Net::IMAP::Client
with the following code
use strict;
use warnings;
use Net::IMAP::Client;
my $user = '[address]#gmail.com';
my $pwd = '[password]';
my $imap = Net::IMAP::Client->new(
server => 'imap.gmail.com',
user => $user,
pass => $pwd,
ssl => 1, # (use SSL? default no)
ssl_verify_peer => 0, # (use ca to verify server, default yes)
port => 993 # (but defaults are sane)
) or die "Could not connect to IMAP server: $_";
$imap->login or
die('Login failed: ' . $imap->last_error)
But the $imap variable is undef and I am getting this error:
Use of uninitialized value $_ in concatenation (.) or string at testIMAP.pl line 9.
Could not connect to IMAP server: at testIMAP.pl line 9.
I have successfully connected to the mailbox using Outlook, but as I'm not getting an error message I'm not sure where to look. Does anyone know what I'm doing wrong here?
A big thanks to zdim for help troubleshooting.
Firstly, zdim pointed out that I had the incorrect error variable. $_ should have been $!
This revealed the error message "Network is unreachable", however I was able to pint and telnet to 'imap.gmail.com' successfully.
The solution to this was found here
Perl IO::Socket::SSL: connect: Network is unreachable .
Changing the use statement in the Net::IMAP::Client module to the following worked:
use IO::Socket::SSL 'inet4';
After this, the connection was established, but the login would fail with
Login failed: [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure)
This is due to Gmail's security features. I received an email that allowed me to confirm that the connection was not malicious, and then subsequent logins were successful.
For others, there may be a few solutions to this last one. You may need to issue an 'app password' If two-step authentication is activated, or you might need to toggle on 'allow less secure apps'
I am trying to use the Mail::Sendmail package to send a mail. Yet I am getting this error:
MAIL FROM: error (530 5.7.57 SMTP; Client was not authenticated to
send anonymous mail during MAIL FROM)
I suspect this has something to do with my santaclaus#christmas.com mail ?
use Mail::Sendmail qw(sendmail %mailcfg);
unshift #{$Mail::Sendmail::mailcfg{'smtp'}} , 'smtp.office365.com:587';
%mail = ( To => 'existingmail#outlook.com',
From => 'santaclaus#christmas.com',
Message => "Time for surprises and gifts is approaching..."
);
sendmail(%mail) or die $Mail::Sendmail::error;
print "OK. Log says:\n", $Mail::Sendmail::log;
It seems that smtp.office365.com requires SMTP AUTH command (SMTP Authentication) to accept email for sending.
Mail::Sendmail DOES NOT support SMTP authentication.
http://search.cpan.org/~mivkovic/Mail-Sendmail-0.79/Sendmail.pm
LIMITATIONS
[...]
No suport for the SMTP AUTH extension.
I need your help/advices on my very short script I wrote in Perl in order to send SMS via SMPP protocol.
I got a SMS gateway which is perfectly working (sending SMS via HTML request or via web interface works), let's say this gateway has IP 192.168.1.15.
Its SMPP service is listening to TCP 2775 (I can successfully telnet to 2775, so I guess SMPP service is working on my SMS gateway)
my $smpp = Net::SMPP->new_transmitter(192.168.1.15,
port=>2775,
system_id =>"administrator",
password =>"passwdexample") or die;
$resp_pdu = $smpp->submit_sm(destination_addr => '+400123456789',
short_message => 'test message') or die;
die "Response indicated error: " . $Resp_PDU->explain_status() if $resp_pdu->status;
When I run the script, here the error I got :
Response indicated error: Incorrect BIND Status for given command (ESME_RINVBNDS TS=0x00000004) at C:\temp\smpptest.pl line .
Unfortunately, I haven't find so much help on internet, but according to this link : SMPP Errors Codes It says :
You must bind first before any other request is handled.
However, my bind is done with new_transmitter, and I don't get any errors at this point, so I don't understand how it cannot bind the TCP session (my credentials are corrects, I tried that in a telnet session).
That's the first time I use such a plugin, so maybe I'm missing something, and maybe someone has already met this error !
Many thanks for your help :-)
Try to quote the IP address:
Net::SMPP->new_transmitter("192.168.1.15", ...);
I use Net::SMTP::SSL to sent email in Perl, and got "454 Error: authentication failed"
Here is my code:
use Net::SMTP::SSL;
$smtp = Net::SMTP::SSL->new($smtp2, Port => $smtp_port2, Timeout => 10, Debug => 1);
$smtp->auth($login2, $password2);
$smtp->mail($login2);
$smtp->to($to);
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: Aspiring error email \n");
$smtp->datasend("Date: $today\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend($message);
$smtp->dataend();
$smtp->quit;
And i got these message:
Net::SMTP::SSL=GLOB(0xf9ab80)<<< 454 Error: authentication failed, system busy
It seem i failed to auth, and i am sure the username and pw is correct.
Thanks so much!!!
454 Error: authentication failed, system busy
These are temporary problems.
The mail server is probably not doing local verification of the password, but is using an external system like a Radius or LDAP server, and the connection to this authentication system failed. Just try again later and hope that the problem got resolved.
If the credentials were wrong the server would have send a 535 status code.
See also the status codes in RFC4954.
i'm using Zend_Mail to send out an email from Aruba PEC.
$config = array('auth'=>'login',
'ssl' => 'ssl',
'port' => 465,
'username'=>'user#pec.it',
'password'=>'pass');
$tr = new Zend_Mail_Transport_Smtp('62.149.152.91',$config);
Zend_Mail::setDefaultTransport($tr);
$mail = new Zend_Mail();
$mail->setBodyHtml('Mail test');
$mail->setFrom('user#pec.it');
$mail->addTo('marco#email.it');
$mail->setSubject('Test');
$mail->send();
but i receive this error: " Could not open socket ".
Now if i try to exceute this script on my local pc it works correctly, but wen i try to exceute it on server in my local area network i receive this error.
than i i try with another ip address (no certifaction account) it works correctly.
(so i think that is a problem of configuration server??)
thanks
You need to have OpenSSL installed on the PC. Is your server Windows? It is a bit of a pain if you are.