diff --git a/src/sbbs3/ctrl/MailCfgDlgUnit.cpp b/src/sbbs3/ctrl/MailCfgDlgUnit.cpp
index 71f381f6a109f52b091f15d257b8f39e799b93a7..892f5cd425ae4dbd1b943f90bed955e46aa000ea 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 2006 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2008 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				*
@@ -96,12 +96,14 @@ void __fastcall TMailCfgDlg::FormShow(TObject *Sender)
     LogFileCheckBox->Checked=MainForm->MailLogFile;
     HostnameCheckBox->Checked
         =!(MainForm->mail_startup.options&MAIL_OPT_NO_HOST_LOOKUP);
+    UseSubPortCheckBox->Checked=MainForm->mail_startup.options&MAIL_OPT_USE_SUBMISSION_PORT;
 
     DefCharsetEdit->Text=AnsiString(MainForm->mail_startup.default_charset);
     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);
+    SubPortEdit->Text=AnsiString(MainForm->mail_startup.submission_port);
     POP3PortEdit->Text=AnsiString(MainForm->mail_startup.pop3_port);
     RelayPortEdit->Text=AnsiString(MainForm->mail_startup.relay_port);
     if(isalnum(MainForm->mail_startup.dns_server[0]))
@@ -181,6 +183,7 @@ void __fastcall TMailCfgDlg::FormShow(TObject *Sender)
     SendMailCheckBoxClick(Sender);
     AllowRelayCheckBoxClick(Sender);
     RelayAuthRadioButtonClick(Sender);
+    UseSubPortCheckBoxClick(Sender);
     PageControl->ActivePage=GeneralTabSheet;
 }
 //---------------------------------------------------------------------------
@@ -215,9 +218,10 @@ void __fastcall TMailCfgDlg::OKBtnClick(TObject *Sender)
     } else
         MainForm->mail_startup.interface_addr=0;
 
-	MainForm->mail_startup.smtp_port=SMTPPortEdit->Text.ToIntDef(25);
-    MainForm->mail_startup.pop3_port=POP3PortEdit->Text.ToIntDef(110);
-    MainForm->mail_startup.relay_port=RelayPortEdit->Text.ToIntDef(25);
+	MainForm->mail_startup.smtp_port=SMTPPortEdit->Text.ToIntDef(IPPORT_SMTP);
+   	MainForm->mail_startup.submission_port=SubPortEdit->Text.ToIntDef(IPPORT_SUBMISSION);
+    MainForm->mail_startup.pop3_port=POP3PortEdit->Text.ToIntDef(IPPORT_POP3);
+    MainForm->mail_startup.relay_port=RelayPortEdit->Text.ToIntDef(IPPORT_SMTP);
     MainForm->mail_startup.max_clients=MaxClientsEdit->Text.ToIntDef(10);
     MainForm->mail_startup.max_inactivity=MaxInactivityEdit->Text.ToIntDef(120);
     MainForm->mail_startup.max_recipients=MaxRecipientsEdit->Text.ToIntDef(100);
@@ -303,6 +307,10 @@ void __fastcall TMailCfgDlg::OKBtnClick(TObject *Sender)
     	MainForm->mail_startup.options|=MAIL_OPT_SMTP_AUTH_VIA_IP;
     else
 	    MainForm->mail_startup.options&=~MAIL_OPT_SMTP_AUTH_VIA_IP;
+ 	if(UseSubPortCheckBox->Checked==true)
+    	MainForm->mail_startup.options|=MAIL_OPT_USE_SUBMISSION_PORT;
+    else
+	    MainForm->mail_startup.options&=~MAIL_OPT_USE_SUBMISSION_PORT;
 
     /* DNSBL */
 	MainForm->mail_startup.options&=
@@ -467,3 +475,12 @@ void __fastcall TMailCfgDlg::RelayAuthRadioButtonClick(TObject *Sender)
 }
 //---------------------------------------------------------------------------
 
+void __fastcall TMailCfgDlg::UseSubPortCheckBoxClick(TObject *Sender)
+{
+    bool enabled = UseSubPortCheckBox->Checked;
+
+    SubPortLabel->Enabled = enabled;
+    SubPortEdit->Enabled = enabled;
+}
+//---------------------------------------------------------------------------
+
diff --git a/src/sbbs3/ctrl/MailCfgDlgUnit.dfm b/src/sbbs3/ctrl/MailCfgDlgUnit.dfm
index 59e50bda6a1969d0823f9ccd4ab4d33ef6c247cf..4786fbef49aa97b321310c5c8c3158f0fe4515fb 100644
--- a/src/sbbs3/ctrl/MailCfgDlgUnit.dfm
+++ b/src/sbbs3/ctrl/MailCfgDlgUnit.dfm
@@ -53,8 +53,8 @@ object MailCfgDlg: TMailCfgDlg
     Top = 4
     Width = 342
     Height = 245
-    ActivePage = SendMailTabSheet
-    TabIndex = 3
+    ActivePage = SMTPTabSheet
+    TabIndex = 1
     TabOrder = 3
     object GeneralTabSheet: TTabSheet
       Caption = 'General'
@@ -161,7 +161,7 @@ object MailCfgDlg: TMailCfgDlg
       end
       object LogFileCheckBox: TCheckBox
         Left = 185
-        Top = 140
+        Top = 172
         Width = 146
         Height = 24
         Hint = 'Save log entries to a file (in your DATA directory)'
@@ -193,17 +193,28 @@ object MailCfgDlg: TMailCfgDlg
         ShowHint = True
         TabOrder = 8
       end
+      object DebugHeadersCheckBox: TCheckBox
+        Left = 185
+        Top = 140
+        Width = 146
+        Height = 24
+        Hint = 'Log all received mail headers (for debugging)'
+        Caption = 'Log RX Headers'
+        ParentShowHint = False
+        ShowHint = True
+        TabOrder = 9
+      end
     end
     object SMTPTabSheet: TTabSheet
       Caption = 'SMTP'
       ImageIndex = 1
-      object TelnetPortLabel: TLabel
+      object SMTPPortLabel: TLabel
         Left = 9
         Top = 12
         Width = 104
         Height = 24
         AutoSize = False
-        Caption = 'Listening Port'
+        Caption = 'Transfer Port'
       end
       object DefaultUserLabel: TLabel
         Left = 9
@@ -214,8 +225,8 @@ object MailCfgDlg: TMailCfgDlg
         Caption = 'Default User'
       end
       object MaxRecipientsLabel: TLabel
-        Left = 9
-        Top = 44
+        Left = 193
+        Top = 76
         Width = 104
         Height = 24
         AutoSize = False
@@ -229,6 +240,14 @@ object MailCfgDlg: TMailCfgDlg
         AutoSize = False
         Caption = 'Max Msg Size'
       end
+      object SubPortLabel: TLabel
+        Left = 9
+        Top = 44
+        Width = 104
+        Height = 24
+        AutoSize = False
+        Caption = 'Submission Port'
+      end
       object SMTPPortEdit: TEdit
         Left = 113
         Top = 12
@@ -239,28 +258,17 @@ object MailCfgDlg: TMailCfgDlg
         ShowHint = True
         TabOrder = 0
       end
-      object DebugHeadersCheckBox: TCheckBox
-        Left = 185
-        Top = 12
-        Width = 146
-        Height = 24
-        Hint = 'Log all received mail headers (for debugging)'
-        Caption = 'Log Headers'
-        ParentShowHint = False
-        ShowHint = True
-        TabOrder = 1
-      end
       object DefaultUserEdit: TEdit
         Left = 113
         Top = 108
-        Width = 185
+        Width = 176
         Height = 24
         Hint = 
           'Mail for unknown users will go into this user'#39's mailbox (e.g. "s' +
           'ysop")'
         ParentShowHint = False
         ShowHint = True
-        TabOrder = 3
+        TabOrder = 2
       end
       object AllowRelayCheckBox: TCheckBox
         Left = 9
@@ -271,28 +279,28 @@ object MailCfgDlg: TMailCfgDlg
         Caption = 'Allow Authenticated Users to Relay Mail'
         ParentShowHint = False
         ShowHint = True
-        TabOrder = 4
+        TabOrder = 3
         OnClick = AllowRelayCheckBoxClick
       end
       object MaxRecipientsEdit: TEdit
-        Left = 113
-        Top = 44
-        Width = 48
+        Left = 296
+        Top = 76
+        Width = 33
         Height = 24
         Hint = 'Maximum number of recipients for a single message'
         ParentShowHint = False
         ShowHint = True
-        TabOrder = 2
+        TabOrder = 1
       end
       object MaxMsgSizeEdit: TEdit
         Left = 113
         Top = 76
-        Width = 80
+        Width = 72
         Height = 24
         Hint = 'Maximum received message size (in bytes)'
         ParentShowHint = False
         ShowHint = True
-        TabOrder = 5
+        TabOrder = 4
       end
       object AuthViaIpCheckBox: TCheckBox
         Left = 9
@@ -305,19 +313,39 @@ object MailCfgDlg: TMailCfgDlg
         Caption = 'Allow Authentication via POP3, Telnet, etc.'
         ParentShowHint = False
         ShowHint = True
-        TabOrder = 6
+        TabOrder = 5
       end
       object NotifyCheckBox: TCheckBox
         Left = 185
-        Top = 44
+        Top = 12
         Width = 146
         Height = 24
         Hint = 'Notify local mail recipients of received e-mails'
         Caption = 'Notify Recipients'
         ParentShowHint = False
         ShowHint = True
+        TabOrder = 6
+      end
+      object SubPortEdit: TEdit
+        Left = 113
+        Top = 44
+        Width = 48
+        Height = 24
+        Hint = 'TCP port number for incoming SMTP submissions (default=587)'
+        ParentShowHint = False
+        ShowHint = True
         TabOrder = 7
       end
+      object UseSubPortCheckBox: TCheckBox
+        Left = 185
+        Top = 44
+        Width = 144
+        Height = 17
+        Hint = 'Enable the SMTP submission port'
+        Caption = 'Enabled'
+        TabOrder = 8
+        OnClick = UseSubPortCheckBoxClick
+      end
     end
     object POP3TabSheet: TTabSheet
       Caption = 'POP3'
diff --git a/src/sbbs3/ctrl/MailCfgDlgUnit.h b/src/sbbs3/ctrl/MailCfgDlgUnit.h
index f333831bdcdea747d0c035659cd570dbb2bd274b..346908f3f7ed3fa22a6a9bd05c99109331b19ede 100644
--- a/src/sbbs3/ctrl/MailCfgDlgUnit.h
+++ b/src/sbbs3/ctrl/MailCfgDlgUnit.h
@@ -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 2005 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2008 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				*
@@ -68,7 +68,7 @@ __published:
     TLabel *MaxInactivityLabel;
     TEdit *MaxInactivityEdit;
     TTabSheet *SMTPTabSheet;
-    TLabel *TelnetPortLabel;
+    TLabel *SMTPPortLabel;
     TEdit *SMTPPortEdit;
     TCheckBox *HostnameCheckBox;
     TCheckBox *DebugTXCheckBox;
@@ -87,7 +87,6 @@ __published:
     TEdit *DeliveryAttemptsEdit;
     TLabel *RescanFreqLabel;
     TEdit *RescanFreqEdit;
-    TCheckBox *DebugHeadersCheckBox;
     TTabSheet *SoundTabSheet;
     TLabel *SMTPSoundLabel;
     TEdit *InboundSoundEdit;
@@ -144,6 +143,10 @@ __published:
     TCheckListBox *AdvancedCheckListBox;
     TLabel *DefCharsetLabel;
     TEdit *DefCharsetEdit;
+    TLabel *SubPortLabel;
+    TEdit *SubPortEdit;
+    TCheckBox *DebugHeadersCheckBox;
+    TCheckBox *UseSubPortCheckBox;
     void __fastcall InboundSoundButtonClick(TObject *Sender);
     void __fastcall OutboundSoundButtonClick(TObject *Sender);
     void __fastcall FormShow(TObject *Sender);
@@ -157,6 +160,7 @@ __published:
 	void __fastcall DNSBLExemptionsButtonClick(TObject *Sender);
 	void __fastcall AllowRelayCheckBoxClick(TObject *Sender);
     void __fastcall RelayAuthRadioButtonClick(TObject *Sender);
+    void __fastcall UseSubPortCheckBoxClick(TObject *Sender);
 private:
 public:
 	virtual __fastcall TMailCfgDlg(TComponent* AOwner);
diff --git a/src/xpdev/sockwrap.h b/src/xpdev/sockwrap.h
index abdaddb2eb1ecb537be11e02350d50e2b558c7f8..c2b073aa1cca309ab30b779a40b174aaa1bcc025 100644
--- a/src/xpdev/sockwrap.h
+++ b/src/xpdev/sockwrap.h
@@ -8,7 +8,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2007 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html		*
  *																			*
  * This library is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU Lesser General Public License		*
@@ -179,26 +179,30 @@ int 	retry_bind(SOCKET s, const struct sockaddr *addr, socklen_t addrlen
 #endif
 
 #ifndef SHUT_RDWR
-#define SHUT_RDWR		2	/* for shutdown() */
+#define SHUT_RDWR			2	/* for shutdown() */
 #endif
 
 #ifndef IPPORT_HTTP
-#define IPPORT_HTTP		80
+#define IPPORT_HTTP			80
 #endif
 #ifndef IPPORT_FTP
-#define IPPORT_FTP		21
+#define IPPORT_FTP			21
 #endif
 #ifndef IPPORT_TELNET
-#define IPPORT_TELNET	23
+#define IPPORT_TELNET		23
 #endif
 #ifndef IPPORT_SMTP
-#define IPPORT_SMTP		25
+#define IPPORT_SMTP			25
 #endif
 #ifndef IPPORT_POP3
-#define IPPORT_POP3		110
+#define IPPORT_POP3			110
 #endif
 #ifndef IPPORT_IDENT
-#define IPPORT_IDENT	113
+#define IPPORT_IDENT		113
 #endif
+#ifndef IPPORT_SUBMISSION
+#define IPPORT_SUBMISSION	587
+#endif
+
 
 #endif	/* Don't add anything after this line */