CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Problem with Email::Send::Gmail

 



zak100
User

Nov 7, 2013, 9:22 AM

Post #1 of 7 (2158 views)
Problem with Email::Send::Gmail Can't Post

 
Hi,
I am trying to send email using following code


Code
 
#!/usr/bin/perl
##use strict;
use warnings;
use Email::Send;
use Email::Send::Gmail;
use Email::Simple::Creator;
use IO::Socket::SSL qw( SSL_VERIFY_NONE );
our ($uri);

RPC::XML::Client->new($uri,
useragent => [
ssl_opts => {
verify_hostname => 0,
SSL_verify_mode => SSL_VERIFY_NONE,
},
],
);

my $email = Email::Simple->create(
header => [
From => 'zulfi60001@gmail.com',
To => 'zulfi60001@gmail.com',
Subject => 'Server down',
],
body => 'The server is down. Start panicing.',
);

my $sender = Email::Send->new(
{ mailer => 'Gmail',
mailer_args => [
username => 'zulfi60001@gmail.com',
password => 'XXX',
]
}
);
eval { $sender->send($email) };
die "Error sending email: $@" if $@;

I am getting following error:


Quote
D:\Zulfi\PERL MAIN FOLDER>perl gmail2.pl
Can't locate object method "new" via package "RPC::XML::Client" (perhaps you for
got to load "RPC::XML::Client"?) at gmail2.pl line 10.

D:\Zulfi\PERL MAIN FOLDER>

Somebody plz help me.



Zulfi.


FishMonger
Veteran / Moderator

Nov 7, 2013, 11:28 AM

Post #2 of 7 (2156 views)
Re: [zak100] Problem with Email::Send::Gmail [In reply to] Can't Post

The error message is pretty clear. You forgot to load the RPC::XML::Client module.

You're also making a mistake by commenting out the use strict; statement.


zak100
User

Nov 8, 2013, 12:07 AM

Post #3 of 7 (2137 views)
Re: [FishMonger] Problem with Email::Send::Gmail [In reply to] Can't Post

Hi,
Thanks for your response. I have created a client object. But I dont know how to load it:

Code
 

#!/usr/bin/perl
use strict;
use warnings;
use Email::Send;
use Email::Send::Gmail;
use Email::Simple::Creator;
use RPC::XML::Server;
use RPC::XML::Client;







use IO::Socket::SSL qw( SSL_VERIFY_NONE );
our ($uri);

$cli=RPC::XML::Client->new($uri,
useragent => [
ssl_opts => {
verify_hostname => 0,
SSL_verify_mode => SSL_VERIFY_NONE,
},
],
);

my $email = Email::Simple->create(
header => [
From => 'zulfi60001@gmail.com',
To => 'zulfi60001@gmail.com',
Subject => 'Server down',
],
body => 'The server is down. Start panicing.',
);

my $sender = Email::Send->new(
{ mailer => 'Gmail',
mailer_args => [
username => 'zulfi60001@gmail.com',
password => 'xxx',
]
}
);
eval { $sender->send($email) };
die "Error sending email: $@" if $@;


I am still getting the same error:


Quote
D:\Zulfi\PERL MAIN FOLDER>perl gmail2.pl
Can't locate object method "new" via package "RPC::XML::Client" (perhaps you for
got to load "RPC::XML::Client"?) at gmail2.pl line 10.

D:\Zulfi\PERL MAIN FOLDER>


Somebody plz guide me.

Zulfi.


FishMonger
Veteran / Moderator

Nov 8, 2013, 6:15 AM

Post #4 of 7 (2126 views)
Re: [zak100] Problem with Email::Send::Gmail [In reply to] Can't Post

You can't be getting the same error from the updated code you posted.

Did you save the file after editing it?

Are you sure you're executing this exact script or are you executing a different version?


zak100
User

Nov 8, 2013, 7:09 AM

Post #5 of 7 (2123 views)
Re: [FishMonger] Problem with Email::Send::Gmail [In reply to] Can't Post

Hi,
Thanks for pointing out my mistake.
I am now showing you the whole thing:

Code
D:\Zulfi\PERL MAIN FOLDER>type gmail2_test.pl 
#!/usr/bin/perl
use strict;
use warnings;
use Email::Send;
use Email::Send::Gmail;
use Email::Simple::Creator;
use RPC::XML::Server;
use RPC::XML::Client;







use IO::Socket::SSL qw( SSL_VERIFY_NONE );
our ($uri);

$cli=RPC::XML::Client->new($uri,
useragent => [
ssl_opts => {
verify_hostname => 0,
SSL_verify_mode => SSL_VERIFY_NONE,
},
],
);

my $email = Email::Simple->create(
header => [
From => 'zulfi60001@gmail.com',
To => 'zulfi60001@gmail.com',
Subject => 'Server down',
],
body => 'The server is down. Start panicing.',
);

my $sender = Email::Send->new(
{ mailer => 'Gmail',
mailer_args => [
username => 'zulfi60001@gmail.com',
password => 'xxx',
]
}
);
eval { $sender->send($email) };
die "Error sending email: $@" if $@;
D:\Zulfi\PERL MAIN FOLDER>perl gmail2_test.pl
Global symbol "$cli" requires explicit package name at gmail2_test.pl line 19.
Execution of gmail2_test.pl aborted due to compilation errors.

D:\Zulfi\PERL MAIN FOLDER>


Can somebody guide me with this error:


Code
 
D:\Zulfi\PERL MAIN FOLDER>perl gmail2_test.pl
Global symbol "$cli" requires explicit package name at gmail2_test.pl line 19.
Execution of gmail2_test.pl aborted due to compilation errors.

D:\Zulfi\PERL MAIN FOLDER>

Thanks for correcting me.
Zulfi.


FishMonger
Veteran / Moderator

Nov 8, 2013, 7:29 AM

Post #6 of 7 (2119 views)
Re: [zak100] Problem with Email::Send::Gmail [In reply to] Can't Post

It's telling you that you forgot to declare the $cli var.

Change:

Code
$cli=RPC::XML::Client->new($uri,

to:

Code
my $cli=RPC::XML::Client->new($uri,


I'd also change:

Code
our ($uri);

to:

Code
my ($uri);



zak100
User

Nov 8, 2013, 8:39 AM

Post #7 of 7 (2113 views)
Re: [FishMonger] Problem with Email::Send::Gmail [In reply to] Can't Post

Hi,
Thanks. Great help. Its working now. I am now able to send email through gmail smtp. The complete code is :

Code
#!/usr/bin/perl 
use strict;
use warnings;
use Email::Send;
use Email::Send::Gmail;
use Email::Simple::Creator;
use RPC::XML::Server;
use RPC::XML::Client;







use IO::Socket::SSL qw( SSL_VERIFY_NONE );
my ($uri);

my $cli=RPC::XML::Client->new($uri,
useragent => [
ssl_opts => {
verify_hostname => 0,
SSL_verify_mode => SSL_VERIFY_NONE,
},
],
);

my $email = Email::Simple->create(
header => [
From => 'zulfi60001@gmail.com',
To => 'zulfi60001@gmail.com',
Subject => 'Server down',
],
body => 'The server is down. Start panicing.',
);

my $sender = Email::Send->new(
{ mailer => 'Gmail',
mailer_args => [
username => 'zulfi60001@gmail.com',
password => 'xxx',
]
}
);
eval { $sender->send($email) };
die "Error sending email: $@" if $@;

It generated a warning but it delivered the email:


Quote

D:\Zulfi\PERL MAIN FOLDER>perl gmail2_test.pl
*******************************************************************
Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
together with SSL_ca_file|SSL_ca_path for verification.
If you really don't want to verify the certificate and keep the
connection open to Man-In-The-Middle attacks please set
SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
*******************************************************************
at C:/Perl64/site/lib/Email/Send/Gmail.pm line 36.

D:\Zulfi\PERL MAIN FOLDER>type gmail_test.pl
The system cannot find the file specified.

D:\Zulfi\PERL MAIN FOLDER>type gmail2_test.pl
#!/usr/bin/perl
use strict;
use warnings;
use Email::Send;
use Email::Send::Gmail;
use Email::Simple::Creator;
use RPC::XML::Server;
use RPC::XML::Client;







use IO::Socket::SSL qw( SSL_VERIFY_NONE );
my ($uri);

my $cli=RPC::XML::Client->new($uri,
useragent => [
ssl_opts => {
verify_hostname => 0,
SSL_verify_mode => SSL_VERIFY_NONE,
},
],
);

my $email = Email::Simple->create(
header => [
From => 'zulfi60001@gmail.com',
To => 'zulfi60001@gmail.com',
Subject => 'Server down',
],
body => 'The server is down. Start panicing.',
);

my $sender = Email::Send->new(
{ mailer => 'Gmail',
mailer_args => [
username => 'zulfi60001@gmail.com',
password => 'sand144rama',
]
}
);
eval { $sender->send($email) };
die "Error sending email: $@" if $@;
D:\Zulfi\PERL MAIN FOLDER>


Zulfi.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives