mikestar20 — 2011-04-13T05:52:50-04:00 — #1
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 184.108.40.206: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 220.127.116.11: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
(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("email@example.com", "John");
myMessage.To.Add(new MailAddress("firstname.lastname@example.org", "Smith"));
SmtpClient mySmtpClient = new SmtpClient();
<smtp deliveryMethod="Network" from="John <email@example.com>">
<network host="smtp.google.com" userName="sender" password="password"/>
Please help me in my quest to learn .NET, Thanks in advance.
nightstalker — 2011-04-13T06:50:27-04:00 — #2
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.
mikestar20 — 2011-04-13T08:27:03-04:00 — #3
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
wwb_99 — 2011-04-13T15:17:04-04:00 — #4
Add a port setting to your configuration to get the right port. Might be a SSL switch as well . . .
mikestar20 — 2011-04-19T00:57:58-04:00 — #5
I added port to my configuration-
<network host="smtp.google.com" port="465" userName="sender" password="password"/>
but still not working.
I changed my SSL settings, and still not working.
wwb_99 — 2011-04-19T14:32:06-04:00 — #6
I think you need to turn on SSL in your app, not in outlook.
mikestar20 — 2011-04-21T09:49:48-04:00 — #7
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.