Sending Email through MailEnable with asp.net C#/VB with SSL on port other than 25 like 465 or 587

Discussion forum for Enterprise Edition.
Post Reply
kiamori
Posts: 243
Joined: Wed Nov 04, 2009 1:39 am
Contact:

Sending Email through MailEnable with asp.net C#/VB with SSL on port other than 25 like 465 or 587

Post by kiamori » Mon Jun 29, 2020 12:22 am

So this works fine on port 25 but for some reason I am unable to get mailenable to accept email from webforms using any port other than 25. Here is the code sample:

Code: Select all

Shared Function SendEmail(ByVal mail_to As String, ByVal mail_toname As String, ByVal mail_from As String, ByVal mail_fromname As String, ByVal mail_subject As String, ByVal mail_body As String, ByVal is_html As Boolean, ByVal invoice_pdf_stream As System.IO.Stream, ByVal invoiceid As Integer) As Boolean
        
        Try
            
            Dim message As New MailMessage()
            message.To.Add(New MailAddress(mail_to, mail_toname))
            message.From = New MailAddress(mail_from, mail_fromname)
            message.Subject = mail_subject
            message.Body = mail_body
            message.IsBodyHtml = is_html
            
            Dim client As New SmtpClient()
            client.Host = mailenableserver
            client.Credentials = New System.Net.NetworkCredential(login), password)
            
            client.Port = 465 'Does not work unless set to 25
            client.EnableSsl = True
            client.Send(message)

            Return True

        Catch
            Return False
        End Try

    End Function
Same result using C#.net code..

And I of course have Listen on alternate ports enabled with auth mode of always allow enabled. Any ideas?
Last edited by kiamori on Mon Jun 29, 2020 12:27 am, edited 1 time in total.

MailEnable-Ian
Site Admin
Posts: 9227
Joined: Mon Mar 22, 2004 4:44 am
Location: Melbourne, Victoria, Australia

Re: Sending Email through MailEnable with web forms with SSL on port other than 25 like 465 or 587

Post by MailEnable-Ian » Mon Jun 29, 2020 12:24 am

Hi,

What is reported within the SMTP activity and debug log file for the inbound connection at the time you send from the from?
Regards,

Ian Margarone
MailEnable Support

kiamori
Posts: 243
Joined: Wed Nov 04, 2009 1:39 am
Contact:

Re: Sending Email through MailEnable with web forms with SSL on port other than 25 like 465 or 587

Post by kiamori » Mon Jun 29, 2020 12:33 am

MailEnable-Ian wrote:
Mon Jun 29, 2020 12:24 am
Hi,

What is reported within the SMTP activity and debug log file for the inbound connection at the time you send from the from?
That is the odd thing, nothing at all. However if I uncheck require SSL it works just fine. For some reason it does not play nice with asp.net while Require SSL is checked even when asp.net has EnableSsl = True

Its also using TLS 1.2 with dotnet framework 4.6 if that helps

kiamori
Posts: 243
Joined: Wed Nov 04, 2009 1:39 am
Contact:

Re: Sending Email through MailEnable with asp.net C#/VB with SSL on port other than 25 like 465 or 587

Post by kiamori » Mon Jun 29, 2020 12:48 am

Log looks like this when Force SSL is not checked,

Code: Select all

		220 me-server-url MailSync+ Service Version 51.2019 ready at 06/28/20 19:32:51	78	0	
EHLO	EHLO servername	250-me-server-url [IP#], this server offers 7 extensions	268	13		
STARTTLS			24	10		
STARTTLS	STARTTLS		24	10		
EHLO	EHLO castle	250-me-server-url [IP#], this server offers 6 extensions	176	13		
AUTH	AUTH ntlm authtoken	535 Invalid Username or Password	400	68	login@me-server-domain
AUTH	{blank}	334 UGFzc3dvcmQ6	18	29	login@me-server-domain
AUTH	{blank}	235 Authenticated	19	10	login@me-server-domain
MAIL	MAIL FROM:<from@me-server-domain>	250 [SMTP:from@me-server-domain] connection from IP# authenticated.	72	29	login@me-server-url
RCPT	RCPT TO:<to@recipientdomain>	250 Requested mail action okay, completed	43	31	login@me-server-domain
debug:

Code: Select all

06/28/20 19:32:52	[1472] Successfully started inbound SSL conversation
06/28/20 19:32:52	ME-I0135: Authenticated User:login@me-server-domain using Authentication Provider Credentials
06/28/20 19:32:52	ME-I0135: Authenticated User:login@me-server-domain using Authentication Provider Credentials
06/28/20 19:32:52	ME-I0101: [1472] Local Delivery: Address ([SMTP:to@recipientdomain]) is local.
06/28/20 19:32:52	ME-I0149: [1472] ID#.MAI was received successfully and delivery thread was initiated
Its also not authenticating correctly in the activity log for some reason, but the IP-relay bypass is working. However, in debug it shows successful authentication twice.

MailEnable-Ian
Site Admin
Posts: 9227
Joined: Mon Mar 22, 2004 4:44 am
Location: Melbourne, Victoria, Australia

Re: Sending Email through MailEnable with asp.net C#/VB with SSL on port other than 25 like 465 or 587

Post by MailEnable-Ian » Wed Jul 01, 2020 12:45 am

Hi,

The enablessl set to true only works using starttls. It will not work over SSL. Therefore you need to set 465 to not require SSL and relay on starttls for that port (as you have seen).
Regards,

Ian Margarone
MailEnable Support

Post Reply