Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 1st, 2011, 11:18 AM
Authorized User
 
Join Date: Feb 2011
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sending Emails with port 465

If you are having issues with sending emails with port 465 like I am see the attached link.

http://blogs.msdn.com/b/webdav_101/a...-port-465.aspx

No fix applied in .net 4.0......

Sending mail using System.Net.Mail with SSL will fail:

System.Net.NetworkCredential aCred = new System.Net.NetworkCredential("myacct", "mypassword");
SmtpClient smtp = new SmtpClient("smtp.mail.myserver.com", 465);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = aCred;


System.Net.Mail only supports “Explicit SSL”.



Explicit SSL
System.Net.Mail only supports “Explicit SSL”. Explicit SSL starts as unencrypted on port 25, then issues a STARTTLS and switches to an Encrypted connection. See RFC 2228.



Explicit SLL would go something like: Connect on 25 -> StartTLS (starts to encrypt) -> authenticate -> send data


If the SMTP server expects SSL/TLS connection right from the start then this will not work.



If you see "530 Must issue a STARTTLS command first" being returned while trying to send a message, then Explicit SSL is what is being expected.



Implicit SSL
There is no way to use Implicit SSL (SMTPS) with System.Net.Mail. Implicit SSL would have the entire connection is wrapped in an SSL layer. A specific port would be used (port 465 is common). There is no formal RFC covering Implicit SSL.



Implicit SLL would go something like: Start SSL (start encryption) -> Connect -> Authenticate -> send data



This is not considered a bug, it’s by design. There are two types of SSL authentication for SMTP, and we only support one with System.Net.Mail (by design) – Explicit SSL.

Windows Mail uses System.Net.Mail to send messages - so it wont work with Implicit SSL. Outlook Express and System.Web.Mail use CDOSYS for sending messages and should work since CDOSYS can work with Explict SSL and Implicit SSL.

Last edited by Cooler; March 1st, 2011 at 06:05 PM..
 
Old March 1st, 2011, 11:51 AM
Authorized User
 
Join Date: Feb 2011
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Solution:

ADD COM reference "Microsoft CDO for Windows 200 Library" to project

Tried it and though it does work not sure of implications.
IMAR are you aware of this work around and issues?

Code:
protected void Page_Load(object sender, EventArgs e)
    {
        string yourEmail = "name@provider";
 
        CDO.Message message = new CDO.Message(); 
        CDO.IConfiguration configuration = message.Configuration; 
        ADODB.Fields fields = configuration.Fields;
        ADODB.Field field = fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"]; 
        field.Value = "smtp.provider"; 
        field = fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"]; 
        field.Value = 465; 
        field = fields["http://schemas.microsoft.com/cdo/configuration/sendusing"]; 
        field.Value = CDO.CdoSendUsing.cdoSendUsingPort; 
        field = fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"]; 
        field.Value = CDO.CdoProtocolsAuthentication.cdoBasic; 
        field = fields["http://schemas.microsoft.com/cdo/configuration/sendusername"]; 
        field.Value = yourEmail; 
        field = fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"]; 
        field.Value = "password"; 
        field = fields["http://schemas.microsoft.com/cdo/configuration/smtpusessl"]; 
        field.Value = "true"; 
        fields.Update();

        message.From = yourEmail; 
        message.To = yourEmail; 
        message.Subject = "Test message."; 
        message.TextBody = "This is a test message. Please disregard.";
        message.Send(); 

        lblMessage.Text = "Message Sent";
    }
 
Old March 1st, 2011, 03:35 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
IMAR are you aware of this work around and issues?
Yes, I was aware of this. This is actually the "old" way of doing this. It works, but stufff in the System.Net namespace is designed to make all of this a lot simpler. I think with the proper configuration you should be able to do the same using managed code in .NET (E.g. the SmtpClient and MailMessage and so on).

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 1st, 2011, 04:36 PM
Authorized User
 
Join Date: Feb 2011
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have tried everything.

The link in OP suggests that implicit SSL with port 465 will not work.
A known issue which doesnt seem to have been resolved in 4.0.....

'An alternate connection method is where an SSL session is established up front before any protocol commands are sent. This connection method is sometimes called SMTP/SSL, SMTP over SSL, or SMTPS and by default uses port 465. This alternate connection method using SSL is not currently supported.'

Last edited by Cooler; March 1st, 2011 at 06:10 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Multiple Emails Brendan Bartley Access 2 January 25th, 2009 01:49 AM
Chapter 9 - Sending eMails havardoj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 January 24th, 2009 07:15 PM
Sending automatic emails maitias C# 2005 3 March 3rd, 2006 09:51 PM
Sending emails from smartphone application. unprsandeep C# 0 March 24th, 2005 02:01 PM
sending emails from vb.Net elan22 General .NET 5 May 27th, 2004 08:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.