[Mono-bugs] [Bug 638426] New: Unhandled exception on trying to send email using SMTP Gmail host from one gmail account to another.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Sep 9 18:53:48 EDT 2010


https://bugzilla.novell.com/show_bug.cgi?id=638426

https://bugzilla.novell.com/show_bug.cgi?id=638426#c0


           Summary: Unhandled exception on trying to send email using SMTP
                    Gmail host from one gmail account to another.
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: x86
        OS/Version: Windows Vista
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: mumtazalishah at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.9)
Gecko/20100824 Firefox/3.6.9 GTB7.1 (.NET CLR 3.5.30729)

/*
The following code throws exception mentioned below on both Mono 2.6 and 
Mono 2.6.4 (via Monodevelop 2.4/DebugX86) but works fine and sends the email
under .Net Framework (both via Monodevelop 2.4/DebugX86 and Visual C# Express
2010.
*/



using System;
using System.Net;
using System.Net.Mail;



class Program
{


    static void Main(string[] args)
    {



        Console.WriteLine("Begin sending email .....");


        var fromAddress = new MailAddress("fromAddress at gmail.com", "fromName");

        var toAddress = new MailAddress("toAddress at gmail.com", "toName");

        const string fromPassword = "fromPassword";

        const string subject = "hello from C#/Mono app";

        const string body = "Testing my emailing C#/Mono code !";



        var smtp = new SmtpClient

        {

            Host = "smtp.gmail.com",

            Port = 587,

            EnableSsl = true,

            DeliveryMethod = SmtpDeliveryMethod.Network,

            Credentials = new NetworkCredential(fromAddress.Address,
fromPassword),

            Timeout = 20000

        };

        using (var message = new MailMessage(fromAddress, toAddress)

        {

            Subject = subject,

            Body = body

        })
        {

            smtp.Send(message);

        }



        Console.WriteLine("End sending email.");

        Console.WriteLine("Press any key to exit...");

        Console.ReadLine();


    }


}


/*  FOLLOWING EXCEPTION THROWN EVERY TIME I RUN THE ABOVE CODE

Unhandled Exception: System.Net.Mail.SmtpException: Message could not be sent.
---> System.IO.IOException: The authentication or decryption has failed. --->
System.InvalidOperationException: SSL authentication error:
RemoteCertificateNotAvailable, RemoteCertificateChainErrors


  at System.Net.Mail.SmtpClient.<callback>m__3 (System.Object sender,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain, SslPolicyErrors
sslPolicyErrors) [0x00037] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\System\System.Net.Mail\SmtpClient.cs:1101 


  at
System.Net.Security.SslStream+<BeginAuthenticateAsClient>c__AnonStorey7.<>m__9
(System.Security.Cryptography.X509Certificates.X509Certificate cert,
System.Int32[] certErrors) [0x000e7] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\System\System.Net.Security\SslStream.cs:385 


  at Mono.Security.Protocol.Tls.SslClientStream.OnRemoteCertificateValidation
(System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Int32[] errors) [0x0000b] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\SslClientStream.cs:380 


  at Mono.Security.Protocol.Tls.SslStreamBase.RaiseRemoteCertificateValidation
(System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Int32[] errors) [0x00000] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\SslStreamBase.cs:205 


  at
Mono.Security.Protocol.Tls.SslClientStream.RaiseServerCertificateValidation
(System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Int32[] certificateErrors) [0x00000] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\SslClientStream.cs:390 


  at
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates
(Mono.Security.X509.X509CertificateCollection certificates) [0x001af] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerCertificate.cs:288 


  at
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1
() [0x00054] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerCertificate.cs:105 


  at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00037]
in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls.Handshake\HandshakeMessage.cs:105 


  at (wrapper remoting-invoke-with-check)
Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process ()


  at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage
(Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00039] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\ClientRecordProtocol.cs:81 


  at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback
(IAsyncResult asyncResult) [0x00127] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\RecordProtocol.cs:397 


  --- End of inner exception stack trace ---


  at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback
(IAsyncResult asyncResult) [0x00049] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\SslStreamBase.cs:108 


  --- End of inner exception stack trace ---


  at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message)
[0x000b7] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\System\System.Net.Mail\SmtpClient.cs:471 


  at Program.Main (System.String[] args) [0x000a5] in
C:\Users\mumtaz\Desktop\Monodevelop projects\Garbage\SendEmail\Program.cs:62 


*/

Reproducible: Always

Steps to Reproduce:
1.Copy paste the above source code and compile with ref to System.dll v2.0
2.Running in Monodevelop in with debugx86 mono 2.6X set  
3.
Actual Results:  

Begin sending email .....

Unhandled Exception: System.Net.Mail.SmtpException: Message could not be sent.
---> System.IO.IOException: The authentication or decryption has failed. --->
System.InvalidOperationException: SSL authentication error:
RemoteCertificateNotAvailable, RemoteCertificateChainErrors


  at System.Net.Mail.SmtpClient.<callback>m__3 (System.Object sender,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain, SslPolicyErrors
sslPolicyErrors) [0x00037] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\System\System.Net.Mail\SmtpClient.cs:1101 


  at
System.Net.Security.SslStream+<BeginAuthenticateAsClient>c__AnonStorey7.<>m__9
(System.Security.Cryptography.X509Certificates.X509Certificate cert,
System.Int32[] certErrors) [0x000e7] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\System\System.Net.Security\SslStream.cs:385 


  at Mono.Security.Protocol.Tls.SslClientStream.OnRemoteCertificateValidation
(System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Int32[] errors) [0x0000b] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\SslClientStream.cs:380 


  at Mono.Security.Protocol.Tls.SslStreamBase.RaiseRemoteCertificateValidation
(System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Int32[] errors) [0x00000] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\SslStreamBase.cs:205 


  at
Mono.Security.Protocol.Tls.SslClientStream.RaiseServerCertificateValidation
(System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Int32[] certificateErrors) [0x00000] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\SslClientStream.cs:390 


  at
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates
(Mono.Security.X509.X509CertificateCollection certificates) [0x001af] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerCertificate.cs:288 


  at
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1
() [0x00054] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerCertificate.cs:105 


  at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00037]
in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls.Handshake\HandshakeMessage.cs:105 


  at (wrapper remoting-invoke-with-check)
Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process ()


  at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage
(Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00039] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\ClientRecordProtocol.cs:81 


  at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback
(IAsyncResult asyncResult) [0x00127] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\RecordProtocol.cs:397 


  --- End of inner exception stack trace ---


  at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback
(IAsyncResult asyncResult) [0x00049] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\Mono.Security\Mono.Security.Protocol.Tls\SslStreamBase.cs:108 


  --- End of inner exception stack trace ---


  at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message)
[0x000b7] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6\mcs\class\System\System.Net.Mail\SmtpClient.cs:471 


  at Program.Main (System.String[] args) [0x000a5] in
C:\Users\mumtaz\Desktop\Monodevelop projects\Garbage\SendEmail\Program.cs:62 

Expected Results:  
Begin sending email .....

End sending email.

Press any key to exit...

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list