<html>
<body>
I'm sorry but maybe I'm missing something. I used field specification to
set the port so it's not 25<br><br>
<tt>msg.Fields[&quot;
<a href="http://schemas.microsoft.com/cdo/configuration/smtpserverport" eudora="autourl">
http://schemas.microsoft.com/cdo/configuration/smtpserverport</a>&quot;]
= 465;<br><br>
</tt>I looked at System.Web.Mail.SmtpClient source code and it reads
those fields from message to set socket connection so it should work, if
it uses port 25 it should give a timeout error, not an immediately socket
exception I think.<br>
Field specification works in MS.NET even if not using exchange server
(The same code works against google in windows environment). <br>
Maybe is one of the most items of MS.NET that does not match the aspected
behavior but looking at Mono source code it should use those fields,
unless there's some problem with TLS. I tried&nbsp; your code on 2.4.2.3
VM and it waits indefinitely, I've to restart apache. Maybe it's because
I don't use Mono 2.6 but this version it's pretty new, in FAQ there's no
version specified, I thought it could be used also with older versions,
it's a problem for me to update.<br><br>
At 13.10 03/06/2010, you wrote:<br>
<blockquote type=cite class=cite cite="">On 03.06.2010 11:10, APS
wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I'm trying so send secured mail with mono using System.Web.Mail in
aspnet.<br>
&gt; I read this<br>
&gt;
&lt;<a href="http://www.mono-project.com/FAQ:_Security#Does_SSL_works_for_SMTP.2C_like_GMail_.3F&gt;http://www.mono-project.com/FAQ:_Security#Does_SSL_works_for_SMTP.2C_like_GMail_.3F" eudora="autourl">
http://www.mono-project.com/FAQ:_Security#Does_SSL_works_for_SMTP.2C_like_GMail_.3F&gt;http://www.mono-project.com/FAQ:_Security#Does_SSL_works_for_SMTP.2C_like_GMail_.3F</a>
<br>
&gt; and I made the described operations but when I try to send the mail
I<br>
&gt; always immediately obtain<br>
&gt;<br>
&gt; System.Web.HttpException: Connection refused ---&gt;<br><br>
This is expected because you're actually connecting on port 25.<br><br>
&gt; System.Web.Mail.MailMessage msg = new
System.Web.Mail.MailMessage();<br>
&gt;<br>
&gt; msg.From = &quot;test@gmail.com&quot;;<br>
&gt; msg.To = &quot;test@gmail.com&quot;;<br>
&gt; msg.Subject = &quot;test&quot;;<br>
&gt; msg.Body = &quot;test&quot;;<br>
&gt; msg.BodyFormat = System.Web.Mail.MailFormat.Html;<br>
&gt;<br>
&gt;
msg.Fields[&quot;<a href="http://schemas.microsoft.com/cdo/configuration/smtpserver" eudora="autourl">
http://schemas.microsoft.com/cdo/configuration/smtpserver</a>&quot;]<br>
&gt; = &quot;smtp.gmail.com&quot;;<br><br>
This fields base configuration is of no use unless you're relaying<br>
the mail through a Microsoft Exchange saver.<br><br>
You're supposed to do something like that (code borrowed<br>
from Abe Gillespie/Mono list):<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static void
SendEmail()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
var sender = &quot;sender@gmail.com&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
var email = &quot;receiver@mail.com&quot;;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
var from = new MailAddress(sender, &quot;Sender&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
var to = new MailAddress(email);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
var mail = new MailMessage(from, to);<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// Set the content.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mail.Subject = &quot;Subject&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mail.Body = &quot;Body&quot;;<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// Send the message.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
SmtpClient smtp = new SmtpClient(&quot;smtp.gmail.com&quot;, 587);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
smtp.EnableSsl = true;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
smtp.Credentials = new NetworkCredential(sender,
&quot;password&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
smtp.Send(mail);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>
<br>
You'll need Mono 2.6.x (or 2.4 + Mono.Security.dll from 2.6,<br>
at you own risk) and don't forget to import the<br>
certs as described here <br>
<a href="http://www.mono-project.com/FAQ:_Security#Does_SSL_works_for_SMTP.2C_like_GMail_.3F" eudora="autourl">
http://www.mono-project.com/FAQ:_Security#Does_SSL_works_for_SMTP.2C_like_GMail_.3F</a>
.<br><br>
Robert<br><br>
_______________________________________________<br>
Mono-aspnet-list mailing list<br>
Mono-aspnet-list@lists.ximian.com<br>
<a href="http://lists.ximian.com/mailman/listinfo/mono-aspnet-list" eudora="autourl">
http://lists.ximian.com/mailman/listinfo/mono-aspnet-list</a><br>
<br>
-- <br>
Il messaggio e' stato analizzato alla ricerca di virus o<br>
contenuti pericolosi da MailScanner, ed e'<br>
risultato non infetto.</blockquote></body>
</html>