Tags:
create new tag
, view all tags

Question

Hi all,

I've been tearing out my hair on this problem and would greatly appreciate help!

During user registration the Net::SMTP constructor from line 297 in TWiki::Net fails to create a valid Net::SMTP object.

  • Net::SMTP instantiates and works just fine in a standalone-script (shown below)
  • sudo 'ing the test script as the appropriate user shows that it's not a privilege problem
  • @INC shows a path where Net::SMTP exists (tested through debug-printing in TWiki::Net)
  • $this->{HELLO_HOST} and $this->{MAIL_HOST} are configured (via the configure script) to the same values as the test script (tested through debug-printing in TWiki::Net)

Any ideas as to what may be causing Net::SMTP to not instantiate?

Thanks in advance!

- m.

p.s. Machine names and e-mails have been changed to protect the not-so-guilty. More information is available on request.

TWiki::Net (lines 293-310)

293    return undef unless( scalar @to );
294
295    my $smtp = 0;
296    if( $this->{HELLO_HOST} ) {
297        $smtp = Net::SMTP->new( $this->{MAIL_HOST},
298                                Hello => $this->{HELLO_HOST},
299                                Debug => $TWiki::cfg{SMTP}{Debug} || 0 );
300    } else {
301        $smtp = Net::SMTP->new( $this->{MAIL_HOST},
302                                Debug => $TWiki::cfg{SMTP}{Debug} || 0 );
303    }
304    my $status = '';
305    my $mess = "ERROR: Can't send mail using Net::SMTP. ";
306    die $mess."Can't connect to '$this->{MAIL_HOST}'" unless $smtp;
307
308    if( $TWiki::cfg{SMTP}{Username} ) {
309        $smtp->auth($TWiki::cfg{SMTP}{Username}, $TWiki::cfg{SMTP}{Password});
310    }

The Error

ERROR: Can't send mail using Net::SMTP. Can't connect to 'myhost.sfsu.edu' at /usr/lib/perl5/5.8.8/CGI/Carp.pm line 314. at /usr/lib/perl5/5.8.8/CGI/Carp.pm line 314

CGI::Carp::realdie('ERROR
    Can\'t send mail using Net::SMTP. Can\'t connect to \'...') called at /usr/lib/perl5/5.8.8/CGI/Carp.pm line 385 
CGI::Carp::die('ERROR
    Can\'t send mail using Net::SMTP. Can\'t connect to \'...') called at /var/www/twiki/lib/TWiki/Net.pm line 306 
    TWiki::Net::_sendEmailByNetSMTP('TWiki::Net=HASH(0x890bf34)', 'Date: Tue, 03 Oct 2006 03:59:24 GMT\x{a}From: Mike Wong \x{a}To: NewUser?...') called at /var/www/twiki/lib/TWiki/UI/Register.pm line 1142 
    TWiki::UI::Register::_sendEmail('TWiki=HASH(0x82eae18)', 'registerconfirm', 'HASH(0x8c3fdb8)') called at /var/www/twiki/lib/TWiki/UI/Register.pm line 428 
    TWiki::UI::Register::_requireVerification('TWiki=HASH(0x82eae18)', '/var/www/twiki/data/RegistrationApprovals') called at /var/www/twiki/lib/TWiki/UI/Register.pm line 375 
    TWiki::UI::Register::registerAndNext('TWiki=HASH(0x82eae18)', '/var/www/twiki/data/RegistrationApprovals') called at /var/www/twiki/lib/TWiki/UI/Register.pm line 90 
    TWiki::UI::Register::register_cgi('TWiki=HASH(0x82eae18)') called at /var/www/twiki/lib/TWiki/UI.pm line 109 
    TWiki::UI::__ANON__() called at /var/www/twiki/lib/CPAN/lib///Error.pm line 379 
    eval {...} called at /var/www/twiki/lib/CPAN/lib///Error.pm line 371 
    Error::subs::try('CODE(0x82672cc)', 'HASH(0x8c3fb48)') called at /var/www/twiki/lib/TWiki/UI.pm line 158 
    TWiki::UI::run('CODE(0x88bbcb4)'
) called 

Standalone Test program (which works)

use Net::SMTP;

my $sender = "myhost.sfsu.edu";
my $host   = "myhost.sfsu.edu";
my $user   = 'mymail@sfsu.edu';

my $smtp = new Net::SMTP( 
	$host,
	Hello => $sender,
	Debug => 0
);

die "Can't connect to '$host'" unless $smtp;

$smtp->mail( $user );
$smtp->to( $user);
$smtp->data( "This is a test: SMTP host=$host, hello=$sender" );
$smtp->dataend();
$smtp->quit();

Environment

TWiki version: TWikiRelease04x00x04
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Linux myhost.sfsu.edu 2.6.15-1.2054_FC5 #1 Tue Mar 14 15:48:33 EST 2006 i686
Web server: Apache/2.2.0
Perl version: Perl 5.8.8
Client OS: MS Windows XP
Web Browser: Mozilla Firefox
Categories: Mail

-- MikeWong - 03 Oct 2006

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

You need to share the salient details of your configuration. It's probably that which is at fault.

-- CrawfordCurrie - 11 Oct 2006

Sorry, closing after more than 30 days...

-- PeterThoeny - 28 Nov 2006

Hi all, sorry for not following up, but the problem was my own ignorance: my sendmail configuration was (correctly) set to accept only "localhost", using this as the sender address works. I still don't know why the standalone script works but now my TWiki configuration sends mail and I don't have time to pursue the issue.

Thanks for all your patience, and I hope this information helps someone.

-- MikeWong - 09 Feb 2007

 
Change status to:
Topic revision: r4 - 2007-02-09 - MikeWong
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.