Question
I am trying to setup Net::SMTP using my ISP's outgoing SMTP server, which requires authentication. Is there a way to make this work, or is there another route I should pursue?
Environment
--
RyanHall - 22 Jun 2006
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
This feature was recently added to the twiki4 branch in svn (to be released with 4.0.3), see
Bugs:Item2292
.
Copy/paste from checkin message on the feature for inspiration (if you want to patch your 4.0.2 installation):
Author: CrawfordCurrie
Date: 2006-05-16 06:57:01 -0500 (Tue, 16 May 2006)
New Revision: 10218
Modified:
twiki/branches/TWikiRelease04x00/lib/TWiki.cfg
twiki/branches/TWikiRelease04x00/lib/TWiki/Net.pm
Log:
Item2292: Added ability to pass auth to the SMTP server. Some servers require it, and this has been a blocker for a number of installs.
Modified: twiki/branches/TWikiRelease04x00/lib/TWiki/Net.pm
===================================================================
--- twiki/branches/TWikiRelease04x00/lib/TWiki/Net.pm 2006-05-15 14:18:09 UTC (rev 10217)
+++ twiki/branches/TWikiRelease04x00/lib/TWiki/Net.pm 2006-05-16 11:57:01 UTC (rev 10218)
@@ -288,14 +288,19 @@
my $smtp = 0;
if( $this->{HELLO_HOST} ) {
$smtp = Net::SMTP->new( $this->{MAIL_HOST},
- Hello => $this->{HELLO_HOST} );
+ Hello => $this->{HELLO_HOST},
+ Debug => $TWiki::cfg{SMTP}{Debug} || 0 );
} else {
- $smtp = Net::SMTP->new( $this->{MAIL_HOST} );
+ $smtp = Net::SMTP->new( $this->{MAIL_HOST},
+ Debug => $TWiki::cfg{SMTP}{Debug} || 0 );
}
my $status = '';
my $mess = "ERROR: Can't send mail using Net::SMTP. ";
die $mess."Can't connect to '$this->{MAIL_HOST}'" unless $smtp;
+ if( $TWiki::cfg{SMTP}{Username} ) {
+ $smtp->auth($TWiki::cfg{SMTP}{Username}, $TWiki::cfg{SMTP}{Password});
+ }
$smtp->mail( $from ) || die $mess.$smtp->message;
$smtp->to( @to, { SkipBad => 1 } ) || die $mess.$smtp->message;
$smtp->data( $text ) || die $mess.$smtp->message;
Modified: twiki/branches/TWikiRelease04x00/lib/TWiki.cfg
===================================================================
--- twiki/branches/TWikiRelease04x00/lib/TWiki.cfg 2006-05-15 14:18:09 UTC (rev 10217)
+++ twiki/branches/TWikiRelease04x00/lib/TWiki.cfg 2006-05-16 11:57:01 UTC (rev 10218)
@@ -926,6 +926,20 @@
$cfg{SMTP}{SENDERHOST} = '';
# **STRING 30**
+# Username for SMTP. Only required if your server requires authentication. If
+# this is left blank, TWiki will not attempt to authenticate the mail sender.
+$cfg{SMTP}{Username} = '';
+
+# **STRING 30**
+# Password for your {SMTP}{Username}.
+$cfg{SMTP}{Password} = '';
+
+# **BOOLEAN**
+# <span class="twikiAlert">EXPERT</span> Set this option on to enable debug
+# mode in SMTP. Output will go to the webserver error log.
+$cfg{SMTP}{Debug} = 0;
+
+# **STRING 30**
# <span class="twikiAlert">EXPERT</span> Some environments require outbound HTTP traffic to go through a proxy
# server. (e.g. proxy.your.company).
# <b>CAUTION</b> This setting can be overridden by a PROXYHOST setting
--
SteffenPoulsen - 22 Jun 2006