Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SendEasy on windows

Status
Not open for further replies.

jabezhunt

Programmer
Feb 4, 2009
2
GB
Hi All,

I'm trying to send emails via a windows server that I only have low level ftp access to using SendEasy as that's what the hosts recommended using. I've got it to find SendEasy eventually but not it doesn't seem to find the functions in SendEasy. Here's my code :-

#!/usr/bin/perl

use CGI;
use warnings;
use strict;
use CGI::Carp qw/fatalsToBrowser/;
use lib 'Mail::SendEasy';

my $query = new CGI;
print $query->header();

print "\@INC is @INC\n<br>";

my $status = Mail::SendEasy::send(
smtp => 'localhost' ,
user => 'foo' ,
pass => 123 ,
from => 'sender@foo.com' ,
from_title => 'Foo Name' ,
reply => 're@foo.com' ,
error => 'error@foo.com' ,
to => 'recp@domain.foo' ,
cc => 'recpcopy@domain.foo' ,
subject => "MAIL Test" ,
msg => "The Plain Msg..." ,
html => "<b>The HTML Msg...</b>" ,
msgid => "0101" ,
) ;


And here's the error message:-

Undefined subroutine &Mail::SendEasy::send called at d:\domains\sarahsfleeces.co.uk\ line 17.

So what's up I can't work it out!

many thanks
Sarah
 
Here:

Code:
use CGI;
use warnings;
use strict;
use CGI::Carp qw/fatalsToBrowser/;
[red]use lib 'Mail::SendEasy';[/red]

This is wrong. The `use lib` pragma just adds a new search path to where modules might be located.

If this module isn't installed globally in the usual places (and I'm assuming it's not), you'll use `use lib` to add the path to where the file `Mail/SendEasy.pm` can be located.

i.e. if your web document root is at C:/users/jabezhunt/html, and your perl script is at C:/users/jabezhunt/html/myscript.pl, and the module is at C:/users/jabezhunt/html/modules/Mail/SendEasy.pm, then you'd do

Code:
use lib "./modules"; # so that "./modules/Mail/SendEasy.pm" exists

or

use lib "C:/users/jabezhunt/modules"; # so that "C:/users/jabezhunt/modules/Mail/SendEasy.pm" exists

Whatever you use for the "use lib" path, in your mind tack on a "/Mail/SendEasy.pm" to the end of that path. If the file would exist there, then you got the right path to it.

And then after that, do "use Mail::SendEasy"

ex:

Code:
use lib "./modules";
use Mail::SendEasy;

# now you can do this
Mail::SendEasy::send (
...

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Hey Kirsle,

That's a really helpful answer thank you:)

ok so now I've got to as below, following your advice:-

Code:
#!/usr/bin/perl

use CGI;
use warnings;
use strict;
use lib 'd:/perl/site/lib';
use CGI::Carp qw/fatalsToBrowser/;
use Mail::SendEasy;

my $query = new CGI;
print $query->header();

print "\@INC is @INC\n<br>";

and this produces the error still:-

Code:
Can't locate Mail/SendEasy.pm in @INC (@INC contains: d:/perl/site/lib d:/perl/lib .) at d:\domains\jabezhunt.co.uk\[URL unfurl="true"]wwwroot\cgi-bin\Send_Details.pl[/URL] line 11.
BEGIN failed--compilation aborted at d:\domains\jabezhunt.co.uk\[URL unfurl="true"]wwwroot\cgi-bin\Send_Details.pl[/URL] line 11.

So it 'still' can't find it - I've got the path to SendEasy from my host, so I know the path is right, but presumably my syntax needs tweaking still?

Cheers
Sarah
 
If that is the path the host gave you and it does not work, you have to ask them why.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
you could try to install it using a script
Code:
@results=`ppm install Mail-Sendeasy`;
print @results;

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I would guess he doesn't have permission to install modules via PPM.

Here's something he can do: go to click the Download link to download it, open it with an archive program that knows how to handle tar.gz (WinRAR comes to mind, but WinZip and 7Zip might also do the job), and get all the *.pm files out of there (make sure you keep their directory structure intact)...

And upload them to your web host, in a folder named "lib" that's in the same location as your Perl script, so that the following files would exist:

your-script.pl
lib/Mail/SendEasy.pm
lib/Mail/SendEasy/AUTH.pm
lib/Mail/SendEasy/Base64.pm
lib/Mail/SendEasy/IOScalar.pm
lib/Mail/SendEasy/SMTP.pm

(to make it easy, just extract the archive and copy the folder named "lib" there to your server and place it next to your Perl script)

And then in your script, just do

Code:
use lib "./lib";
use Mail::SendEasy;

Then it'll use your uploaded copy of Mail::SendEasy that exists in ./lib (the dot means "current directory", so "./lib" means "the lib folder that's in the same place as the perl script").

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top