Error on sending Email, Please Help! :(

Hi All,
from past few weeks i’m unable to overcome from this error in ASP.Net when sending email(I am a beginner in .NET). Would be great if i could get a solution here. Thanks.
Error Page-(Internet Explorer)
Server Error in ‘/Site’ Application.

An attempt was made to access a socket in a way forbidden by its access permissions 72.14.225.72:25
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 72.14.225.72:25

Source Error:

Line 25:
Line 26: SmtpClient mySmtpClient = new SmtpClient();
Line 27: mySmtpClient.Send(myMessage);
Line 28: }
Line 29: }

Source File: c:\BegASPNET\Site\Demos\Email.aspx.cs Line: 27
Stack Trace:
(Full of Codes, not needed i guess, ??)


some part of “aspx.cs” page:
protected void Page_Load(object sender, EventArgs e)
{
MailMessage myMessage = new MailMessage();
myMessage.Subject = “Test Message”;
myMessage.Body = “Hello world, from planet wrox”;

    myMessage.From = new MailAddress("sender@gmail.com", "John");
    myMessage.To.Add(new MailAddress("receiver@gmail.com", "Smith"));

    SmtpClient mySmtpClient = new SmtpClient();
    mySmtpClient.Send(myMessage);
}

web.config page:
<system.net>
<mailSettings>
<smtp deliveryMethod=“Network” from=“John <sender@gmail.com>”>
<network host=“smtp.google.com” userName=“sender” password=“password”/>
</smtp>
</mailSettings>
</system.net>
</configuration>


Please help me in my quest to learn .NET, Thanks in advance.
Regards,
mikestar20

Well, if you are trying to use gmail servers to send email, it is not going to be that simple. You need to use SSL ports instead of standard ports and you need to setup your username and password in your config file as you did.

how do i use SSL port instead of standard port??
and i already set my outlook express settings using this link-
Outlook Express - Gmail Help

Add a port setting to your configuration to get the right port. Might be a SSL switch as well . . .

I added port to my configuration-
<network host=“smtp.google.comport=“465” userName=“sender” password=“password”/>
but still not working.

I changed my SSL settings, and still not working.

I think you need to turn on SSL in your app, not in outlook.

how to turn SSL in app?? i’m new to .NET please help. If configuring mail settings for gmail is difficult then i can change to yahoo as well.
Thanks