Hi,

I'm trying so send secured mail with mono using System.Web.Mail in aspnet.
I read this <http://www.mono-project.com/FAQ:_Security#Does_SSL_works_for_SMTP.2C_like_GMail_.3F>http://www.mono-project.com/FAQ:_Security#Does_SSL_works_for_SMTP.2C_like_GMail_.3F and I made the described operations but when I try to send the mail I always immediately obtain

System.Web.HttpException: Connection refused ---> System.Net.Sockets.SocketException: Connection refused at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remote_end) [0x00000] at System.Net.Sockets.TcpClient.Connect (System.Net.IPEndPoint remote_end_point) [0x00000] at System.Net.Sockets.TcpClient.Connect (System.Net.IPAddress[] ipAddresses, Int32 port) [0x00000]
--- End of inner exception stack trace ---
at System.Web.Mail.SmtpMail.Send (System.Web.Mail.MailMessage message) [0x00000]

Launching this command

openssl s_client -connect smtp.gmail.com:465

I obtain

220 mx.google.com ESMTP

so I think it's not a problem of blocked ports and so on. Can anyone help me on understanding the problem? The code is the following. Running it with .NET Framework result in an error due to invalid sender address but the connection works. Thanks in advance.

System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage();

msg.From = "[email protected]";
msg.To = "[email protected]";
msg.Subject = "test";
msg.Body = "test";
msg.BodyFormat = System.Web.Mail.MailFormat.Html;

msg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver";] = "smtp.gmail.com"; msg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport";] = 465;
msg.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing";] = 2;

msg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpusessl";] = true;

msg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate";] = 1; msg.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername";] = "test"; msg.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword";] = "test";

System.Web.Mail.SmtpMail.Send(msg);
_______________________________________________
Mono-aspnet-list mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/mono-aspnet-list

Reply via email to