diff --git a/src/sbbs3/ctrl/MailCfgDlgUnit.cpp b/src/sbbs3/ctrl/MailCfgDlgUnit.cpp
index 1da50eb7491a54b729e389196efb84093b536b89..2154ff807f27594a11ffd7c3d1915b613dbb257c 100644
--- a/src/sbbs3/ctrl/MailCfgDlgUnit.cpp
+++ b/src/sbbs3/ctrl/MailCfgDlgUnit.cpp
@@ -6,7 +6,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html		*
  *																			*
  * This program is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU General Public License				*
@@ -98,6 +98,8 @@ void __fastcall TMailCfgDlg::FormShow(TObject *Sender)
         =!(MainForm->mail_startup.options&MAIL_OPT_NO_HOST_LOOKUP);
 
     RelayServerEdit->Text=AnsiString(MainForm->mail_startup.relay_server);
+    RelayAuthNameEdit->Text=AnsiString(MainForm->mail_startup.relay_user);
+    RelayAuthPassEdit->Text=AnsiString(MainForm->mail_startup.relay_pass);
     SMTPPortEdit->Text=AnsiString(MainForm->mail_startup.smtp_port);
     POP3PortEdit->Text=AnsiString(MainForm->mail_startup.pop3_port);
     RelayPortEdit->Text=AnsiString(MainForm->mail_startup.relay_port);
@@ -126,6 +128,13 @@ void __fastcall TMailCfgDlg::FormShow(TObject *Sender)
         &MAIL_OPT_DEBUG_POP3;
     RelayRadioButton->Checked=MainForm->mail_startup.options
     	&MAIL_OPT_RELAY_TX;
+    RelayAuthPlainRadioButton->Checked=MainForm->mail_startup.options
+        &MAIL_OPT_RELAY_AUTH_PLAIN;
+    RelayAuthLoginRadioButton->Checked=MainForm->mail_startup.options
+        &MAIL_OPT_RELAY_AUTH_LOGIN;
+    RelayAuthCramMD5RadioButton->Checked=MainForm->mail_startup.options
+        &MAIL_OPT_RELAY_AUTH_CRAM_MD5;
+
 #if 0 /* this is a stupid option */
     UserNumberCheckBox->Checked=MainForm->mail_startup.options
     	&MAIL_OPT_ALLOW_RX_BY_NUMBER;
@@ -155,6 +164,7 @@ void __fastcall TMailCfgDlg::FormShow(TObject *Sender)
 	POP3EnabledCheckBoxClick(Sender);
     SendMailCheckBoxClick(Sender);
     AllowRelayCheckBoxClick(Sender);
+    RelayAuthRadioButtonClick(Sender);
     PageControl->ActivePage=GeneralTabSheet;
 }
 //---------------------------------------------------------------------------
@@ -201,6 +211,10 @@ void __fastcall TMailCfgDlg::OKBtnClick(TObject *Sender)
         ,DNSServerEdit->Text.c_str());
     SAFECOPY(MainForm->mail_startup.relay_server
         ,RelayServerEdit->Text.c_str());
+    SAFECOPY(MainForm->mail_startup.relay_user
+        ,RelayAuthNameEdit->Text.c_str());
+    SAFECOPY(MainForm->mail_startup.relay_pass
+        ,RelayAuthPassEdit->Text.c_str());
     SAFECOPY(MainForm->mail_startup.inbound_sound
         ,InboundSoundEdit->Text.c_str());
     SAFECOPY(MainForm->mail_startup.outbound_sound
@@ -216,6 +230,13 @@ void __fastcall TMailCfgDlg::OKBtnClick(TObject *Sender)
     	MainForm->mail_startup.options|=MAIL_OPT_RELAY_TX;
     else
 	    MainForm->mail_startup.options&=~MAIL_OPT_RELAY_TX;
+    MainForm->mail_startup.options&=~(MAIL_OPT_RELAY_AUTH_MASK);
+    if(RelayAuthLoginRadioButton->Checked==true)
+        MainForm->mail_startup.options|=MAIL_OPT_RELAY_AUTH_LOGIN;
+    else if(RelayAuthPlainRadioButton->Checked==true)
+        MainForm->mail_startup.options|=MAIL_OPT_RELAY_AUTH_PLAIN;
+    else if(RelayAuthCramMD5RadioButton->Checked==true)
+        MainForm->mail_startup.options|=MAIL_OPT_RELAY_AUTH_CRAM_MD5;
 	if(DebugTXCheckBox->Checked==true)
     	MainForm->mail_startup.options|=MAIL_OPT_DEBUG_TX;
     else
@@ -302,11 +323,13 @@ void __fastcall TMailCfgDlg::POP3SoundButtonClick(TObject *Sender)
 
 void __fastcall TMailCfgDlg::DNSRadioButtonClick(TObject *Sender)
 {
-    RelayServerEdit->Enabled=RelayRadioButton->Checked;
-    RelayPortEdit->Enabled=RelayRadioButton->Checked;
-    RelayPortLabel->Enabled=RelayRadioButton->Checked;
-    DNSServerEdit->Enabled=!RelayRadioButton->Checked;
-    TcpDnsCheckBox->Enabled=!RelayRadioButton->Checked;
+    bool checked = RelayRadioButton->Checked && SendMailCheckBox->Checked;
+    RelayTabSheet->TabVisible=checked;
+    RelayPortEdit->Enabled=checked;
+    RelayPortLabel->Enabled=checked;
+    DNSServerEdit->Enabled=!checked;
+    DNSServerLabel->Enabled=!checked;
+    TcpDnsCheckBox->Enabled=!checked;
 }
 //---------------------------------------------------------------------------
 
@@ -334,15 +357,11 @@ void __fastcall TMailCfgDlg::SendMailCheckBoxClick(TObject *Sender)
     DNSServerEdit->Enabled=checked;
     TcpDnsCheckBox->Enabled=checked;
     RelayRadioButton->Enabled=checked;
-    RelayServerEdit->Enabled=checked;
-    RelayPortEdit->Enabled=checked;
-    RelayPortLabel->Enabled=checked;
     OutboundSoundEdit->Enabled=checked;
     OutboundSoundLabel->Enabled=checked;
     OutboundSoundButton->Enabled=checked;
 
-    if(checked)
-        DNSRadioButtonClick(Sender);
+    DNSRadioButtonClick(Sender);
 }
 //---------------------------------------------------------------------------
 
@@ -389,3 +408,14 @@ void __fastcall TMailCfgDlg::AllowRelayCheckBoxClick(TObject *Sender)
 }
 //---------------------------------------------------------------------------
 
+void __fastcall TMailCfgDlg::RelayAuthRadioButtonClick(TObject *Sender)
+{
+    bool enabled = !RelayAuthNoneRadioButton->Checked;
+
+    RelayAuthNameEdit->Enabled=enabled;
+    RelayAuthPassEdit->Enabled=enabled;
+    RelayAuthNameLabel->Enabled=enabled;
+    RelayAuthPassLabel->Enabled=enabled;
+}
+//---------------------------------------------------------------------------
+
diff --git a/src/sbbs3/ctrl/MailCfgDlgUnit.dfm b/src/sbbs3/ctrl/MailCfgDlgUnit.dfm
index ec4620dc40be10e47a8fc5502f092ea745b19a47..a7ac3158265120b4abd59338da3997836e3e3566 100644
--- a/src/sbbs3/ctrl/MailCfgDlgUnit.dfm
+++ b/src/sbbs3/ctrl/MailCfgDlgUnit.dfm
@@ -1,6 +1,6 @@
 object MailCfgDlg: TMailCfgDlg
-  Left = 841
-  Top = 501
+  Left = 501
+  Top = 339
   BorderStyle = bsDialog
   Caption = 'Mail Server Configuration'
   ClientHeight = 303
@@ -53,8 +53,8 @@ object MailCfgDlg: TMailCfgDlg
     Top = 4
     Width = 342
     Height = 245
-    ActivePage = DNSBLTabSheet
-    TabIndex = 5
+    ActivePage = RelayTabSheet
+    TabIndex = 4
     TabOrder = 3
     object GeneralTabSheet: TTabSheet
       Caption = 'General'
@@ -367,15 +367,6 @@ object MailCfgDlg: TMailCfgDlg
     object SendMailTabSheet: TTabSheet
       Caption = 'SendMail'
       ImageIndex = 3
-      object RelayPortLabel: TLabel
-        Left = 197
-        Top = 172
-        Width = 39
-        Height = 26
-        Alignment = taRightJustify
-        AutoSize = False
-        Caption = 'Port'
-      end
       object DeliveryAttemptsLabel: TLabel
         Left = 9
         Top = 44
@@ -394,15 +385,22 @@ object MailCfgDlg: TMailCfgDlg
         AutoSize = False
         Caption = 'Frequency'
       end
+      object DNSServerLabel: TLabel
+        Left = 9
+        Top = 152
+        Width = 72
+        Height = 16
+        Caption = 'DNS Server'
+      end
       object DNSRadioButton: TRadioButton
         Left = 9
-        Top = 76
-        Width = 104
+        Top = 116
+        Width = 184
         Height = 26
         Hint = 
           'Send mail directly to addressed mail server (requires DNS server' +
           ' access)'
-        Caption = 'DNS Server'
+        Caption = 'Direct Mail Delivery'
         Checked = True
         ParentShowHint = False
         ShowHint = True
@@ -412,9 +410,9 @@ object MailCfgDlg: TMailCfgDlg
       end
       object DNSServerEdit: TEdit
         Left = 113
-        Top = 76
+        Top = 148
         Width = 185
-        Height = 21
+        Height = 24
         Hint = 'Host name or IP address of your ISP'#39's DNS server'
         ParentShowHint = False
         ShowHint = True
@@ -422,7 +420,7 @@ object MailCfgDlg: TMailCfgDlg
       end
       object TcpDnsCheckBox: TCheckBox
         Left = 250
-        Top = 108
+        Top = 180
         Width = 65
         Height = 24
         Hint = 'Use TCP packets (instead of UDP) for DNS queries'
@@ -433,43 +431,21 @@ object MailCfgDlg: TMailCfgDlg
       end
       object RelayRadioButton: TRadioButton
         Left = 9
-        Top = 140
-        Width = 104
+        Top = 84
+        Width = 192
         Height = 26
         Hint = 'Route all mail through an SMTP relay server'
-        Caption = 'Relay Server'
+        Caption = 'Use Relay Server'
         ParentShowHint = False
         ShowHint = True
         TabOrder = 6
         OnClick = DNSRadioButtonClick
       end
-      object RelayServerEdit: TEdit
-        Left = 113
-        Top = 140
-        Width = 185
-        Height = 21
-        Hint = 
-          'Host name or IP address of external SMTP server (for relaying ma' +
-          'il)'
-        ParentShowHint = False
-        ShowHint = True
-        TabOrder = 7
-      end
-      object RelayPortEdit: TEdit
-        Left = 250
-        Top = 172
-        Width = 48
-        Height = 21
-        Hint = 'TCP port number for the SMTP relay server (default=25)'
-        ParentShowHint = False
-        ShowHint = True
-        TabOrder = 8
-      end
       object DeliveryAttemptsEdit: TEdit
         Left = 113
         Top = 44
         Width = 48
-        Height = 21
+        Height = 24
         Hint = 'Maximum number of delivery attempts'
         ParentShowHint = False
         ShowHint = True
@@ -479,7 +455,7 @@ object MailCfgDlg: TMailCfgDlg
         Left = 250
         Top = 44
         Width = 48
-        Height = 21
+        Height = 24
         Hint = 'Seconds between message base rescans'
         ParentShowHint = False
         ShowHint = True
@@ -498,6 +474,131 @@ object MailCfgDlg: TMailCfgDlg
         OnClick = SendMailCheckBoxClick
       end
     end
+    object RelayTabSheet: TTabSheet
+      Caption = 'Relay'
+      ImageIndex = 6
+      object RelayPortLabel: TLabel
+        Left = 240
+        Top = 12
+        Width = 33
+        Height = 26
+        Alignment = taRightJustify
+        AutoSize = False
+        Caption = 'Port'
+      end
+      object RelayServerLabel: TLabel
+        Left = 9
+        Top = 12
+        Width = 40
+        Height = 16
+        Caption = 'Server'
+      end
+      object RelayServerEdit: TEdit
+        Left = 65
+        Top = 12
+        Width = 168
+        Height = 24
+        Hint = 
+          'Host name or IP address of external SMTP server (for relaying ma' +
+          'il)'
+        ParentShowHint = False
+        ShowHint = True
+        TabOrder = 0
+      end
+      object RelayPortEdit: TEdit
+        Left = 282
+        Top = 12
+        Width = 39
+        Height = 24
+        Hint = 'TCP port number for the SMTP relay server (default=25)'
+        ParentShowHint = False
+        ShowHint = True
+        TabOrder = 1
+      end
+      object RelayAuthGroupBox: TGroupBox
+        Left = 9
+        Top = 41
+        Width = 320
+        Height = 160
+        Caption = 'Authentication:'
+        TabOrder = 2
+        object RelayAuthNameLabel: TLabel
+          Left = 16
+          Top = 92
+          Width = 80
+          Height = 26
+          AutoSize = False
+          Caption = 'Name'
+        end
+        object RelayAuthPassLabel: TLabel
+          Left = 16
+          Top = 121
+          Width = 80
+          Height = 25
+          AutoSize = False
+          Caption = 'Password'
+        end
+        object RelayAuthNoneRadioButton: TRadioButton
+          Left = 16
+          Top = 28
+          Width = 113
+          Height = 24
+          Caption = 'None'
+          Checked = True
+          TabOrder = 0
+          TabStop = True
+          OnClick = RelayAuthRadioButtonClick
+        end
+        object RelayAuthPlainRadioButton: TRadioButton
+          Left = 169
+          Top = 28
+          Width = 113
+          Height = 24
+          Caption = 'Plain'
+          TabOrder = 1
+          OnClick = RelayAuthRadioButtonClick
+        end
+        object RelayAuthLoginRadioButton: TRadioButton
+          Left = 169
+          Top = 57
+          Width = 113
+          Height = 24
+          Caption = 'Login'
+          TabOrder = 2
+          OnClick = RelayAuthRadioButtonClick
+        end
+        object RelayAuthCramMD5RadioButton: TRadioButton
+          Left = 16
+          Top = 57
+          Width = 113
+          Height = 24
+          Caption = 'CRAM-MD5'
+          TabOrder = 3
+          OnClick = RelayAuthRadioButtonClick
+        end
+        object RelayAuthNameEdit: TEdit
+          Left = 105
+          Top = 92
+          Width = 185
+          Height = 24
+          Hint = 'User name to authenticate as'
+          ParentShowHint = False
+          ShowHint = True
+          TabOrder = 4
+        end
+        object RelayAuthPassEdit: TEdit
+          Left = 105
+          Top = 121
+          Width = 185
+          Height = 24
+          Hint = 'Password for authentication'
+          ParentShowHint = False
+          PasswordChar = '*'
+          ShowHint = True
+          TabOrder = 5
+        end
+      end
+    end
     object SoundTabSheet: TTabSheet
       Caption = 'Sound'
       ImageIndex = 4
@@ -529,7 +630,7 @@ object MailCfgDlg: TMailCfgDlg
         Left = 113
         Top = 12
         Width = 185
-        Height = 21
+        Height = 24
         Hint = 'Sound file to play when inbound SMTP connections are accepted'
         ParentShowHint = False
         ShowHint = True
@@ -548,7 +649,7 @@ object MailCfgDlg: TMailCfgDlg
         Left = 113
         Top = 76
         Width = 185
-        Height = 21
+        Height = 24
         Hint = 'Sound file to play when accepting POP3 connections'
         ParentShowHint = False
         ShowHint = True
@@ -567,7 +668,7 @@ object MailCfgDlg: TMailCfgDlg
         Left = 113
         Top = 44
         Width = 185
-        Height = 21
+        Height = 24
         Hint = 'Sound file to play when sending mail'
         ParentShowHint = False
         ShowHint = True
diff --git a/src/sbbs3/ctrl/MailCfgDlgUnit.h b/src/sbbs3/ctrl/MailCfgDlgUnit.h
index 7479c380bc42ffd8b45156983b5cd5e70cbe8f15..ad0feca34a53314adb023d0bcb64abecdbd70063 100644
--- a/src/sbbs3/ctrl/MailCfgDlgUnit.h
+++ b/src/sbbs3/ctrl/MailCfgDlgUnit.h
@@ -82,9 +82,6 @@ __published:
     TEdit *DNSServerEdit;
     TCheckBox *TcpDnsCheckBox;
     TRadioButton *RelayRadioButton;
-    TEdit *RelayServerEdit;
-    TEdit *RelayPortEdit;
-    TLabel *RelayPortLabel;
     TLabel *DeliveryAttemptsLabel;
     TEdit *DeliveryAttemptsEdit;
     TLabel *RescanFreqLabel;
@@ -127,6 +124,21 @@ __published:
 	TEdit *MaxMsgSizeEdit;
 	TCheckBox *AuthViaIpCheckBox;
 	TCheckBox *NotifyCheckBox;
+    TTabSheet *RelayTabSheet;
+    TEdit *RelayServerEdit;
+    TEdit *RelayPortEdit;
+    TLabel *RelayPortLabel;
+    TLabel *DNSServerLabel;
+    TLabel *RelayServerLabel;
+    TGroupBox *RelayAuthGroupBox;
+    TRadioButton *RelayAuthNoneRadioButton;
+    TRadioButton *RelayAuthPlainRadioButton;
+    TRadioButton *RelayAuthLoginRadioButton;
+    TRadioButton *RelayAuthCramMD5RadioButton;
+    TLabel *RelayAuthNameLabel;
+    TEdit *RelayAuthNameEdit;
+    TLabel *RelayAuthPassLabel;
+    TEdit *RelayAuthPassEdit;
     void __fastcall InboundSoundButtonClick(TObject *Sender);
     void __fastcall OutboundSoundButtonClick(TObject *Sender);
     void __fastcall FormShow(TObject *Sender);
@@ -139,6 +151,7 @@ __published:
 	void __fastcall DNSBLServersButtonClick(TObject *Sender);
 	void __fastcall DNSBLExemptionsButtonClick(TObject *Sender);
 	void __fastcall AllowRelayCheckBoxClick(TObject *Sender);
+    void __fastcall RelayAuthRadioButtonClick(TObject *Sender);
 private:
 public:
 	virtual __fastcall TMailCfgDlg(TComponent* AOwner);