Gossamer Forum
Quote Reply
Using GT
Hi, I'm interested in developing pluggins and want to get
a handle on using the GT modules. So I'm trying to write a
standalone script to simple sentd out some mail as per the
examples in the Developer doco for GT.

use GT::Mail ;
GT::Mail->send (
smtp => 'my.server,here',
to => 'doug@cygnus.uwa.edu.au',
from => 'Booking',
subject => 'Hello!!',
msg => 'I am a text email'
) or die "Error: $GT::Mail::error";

And I get the message (not the die error message)

"GT::Mail::Parts (10748): Unknown method 'emails' called at GT/Mail/Send.pm line 100. "

Hmmn is there anything I should know about using the GT
package outside of links?

regards doug


Quote Reply
Re: Using GT In reply to
You probably need to use lib '.../GT' at the very least. You might need
to use lib '.../admin'. I would imagine that the GT module could stand alone, if you included it, nd you wouldn't have to include the Links:: stuff. But at this early stage you might.

Every program I've tried has used:

use lib '.../admin';
use Links qw/$DB $CFG/;

at the very least.


This is really a job for Super-Alex though!




PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://LinkSQL.com/FAQ


Quote Reply
Re: Using GT In reply to
Here is the full script - its in the links dir (next to add.cgi, jump.cgi etc) and using full headers as suggested still fails.

--------------------
#!/usr/bin/perl
use strict;
use lib '/home/httpd/html/links/admin';
use Links qw/$DB $IN $CFG $USER/;
use Links::SiteHTML;
use GT::Mail;
print $IN->header();
print "ok" ;
mySendMail() ;

sub mySendMail
{
GT::Mail->send (
smtp => 'mail.mydomain',
to => 'me@somewhere.com',
from => 'me@somewhere.com',
subject => 'Hello ...',
msg => 'I am a text email'
) or die "Error: $GT::Mail::error";
}
-----------------------------
And when run get:

A fatal error has occured:

GT::Mail::Parts (12325): Unknown method 'emails' called at /home/httpd/html/links/admin/GT/Mail/Send.pm line 100.

Please enable debugging in setup for more details.
------------------------------------------

Quote Reply
Re: Using GT In reply to
IS this part....

print $IN->header();
print "ok" ;

...to show the successful sending of the email?.....If so it should go at the bottom because it will print whether the email is sent or not.

Try using.......

$to = $CFG->{db_admin_email};
$from = "someone@somewhere.com";
$subject = "Testing Testing\n";
$msg = qq|TESTING|;

require GT::Mail;
$GT::Mail::error ||= ''; # Silence -w
GT::Mail->send (
smtp => $CFG->{db_smtp_server},
sendmail => $CFG->{db_mail_path},
from => $from,
subject => $subject,
to => $to,
msg => $msg,
debug => $Links::DEBUG
) or Links::fatal ("Unable to send mail: $GT::Mail::error");

Put this at the top of your script.....

use strict;
use lib '/PATH/TO/admin';
use Links qw/$DB $IN $CFG/;
use Links::SiteHTML;

Don't quote me on that though........



Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Using GT In reply to
Hi,

There is a bug in SMTP sending of mails that produces that error. I had updated the .tar.gz silently about 6 hours after 2.0.1 was released, so if you just grab it again it will be fixed.

Sorry about that!

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Using GT In reply to
Thanks all working now. Just one other thing if the message
is empty it wipes out the 'From' and Subject lines of an email.

eg below if the $Message is empty the email is screwed.

sub mySendMail ($$$$)
{
($To,$From,$Subject,$Message) = @_ ;

GT::Mail->send (
smtp => $SMTP,
to => $To,
from => $From,
subject => $Subject,
msg => $Message,
debug => 0
) or die "Error: $GT::Mail::error";
}