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 18.104.22.168: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 22.214.171.124: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.
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.com" port="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.