Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 29th, 2011, 11:08 AM
Registered User
 
Join Date: Mar 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Configuring your website for sending Email

I have tried to send email with the exact same code as in pg 318. I have a gmail account which is also setup in Outlook. When sending the email, got error message:
No connection could be made because the target machine actively refused it 74.125.157.109:587
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: No connection could be made because the target machine actively refused it 74.125.157.109:587
 
Old March 29th, 2011, 11:14 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Can you post the code and configuration you're using?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 29th, 2011, 11:27 AM
Registered User
 
Join Date: Mar 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Windows XP

Code:
Web.config
<system.net>
<mailSettings>
<!-- <smtp deliveryMethod="Network" from="[email protected]">
<network
enableSsl="true"
port="587"
userName="[email protected]"
password="mypassword"
host="smtp.gmail.com"/>
</smtp> -->
<smtp deliveryMethod="SpecifiedPickupDirectory" from ="[email protected]">
<specifiedPickupDirectory pickupDirectoryLocation="D:\Training\TempMail" />
</smtp>
</mailSettings>
</system.net>

Note: when I use "deliveryMethod="SpecifiedPickupDirectory"", it works.
 
Old March 29th, 2011, 11:33 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

And how does the code you're using look?

I just copied your code (the gmail version) into my Planet Wrox sample project, changed the user name and password and ran Email.aspx from the Demos folder. Within seconds I receieved the test message. So, conceptually, the configuration code is OK.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
bnazeem (March 29th, 2011)
 
Old March 29th, 2011, 11:43 AM
Registered User
 
Join Date: Mar 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I try it again, this is the message:
No connection could be made because the target machine actively refused it 74.125.91.109:587
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: No connection could be made because the target machine actively refused it 74.125.91.109:587

Source Error:

Line 18:
Line 19: SmtpClient mySmtpClient = new SmtpClient();
Line 20: mySmtpClient.Send(myMessage);
Line 21:
Line 22: }


Source File: d:\Training\BegASPNET\Site2\Demos\Email.aspx.cs Line: 20

Stack Trace:

[SocketException (0x274d): No connection could be made because the target machine actively refused it 74.125.91.109:587]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +225
System.Net.ServicePoint.ConnectSocketInternal(Bool ean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +279

[WebException: Unable to connect to the remote server]
System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +6054548
System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +314
System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21
System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +322
System.Net.Mail.SmtpConnection.GetConnection(Servi cePoint servicePoint) +146
System.Net.Mail.SmtpTransport.GetConnection(Servic ePoint servicePoint) +170
System.Net.Mail.SmtpClient.GetConnection() +50
System.Net.Mail.SmtpClient.Send(MailMessage message) +1484

[SmtpException: Failure sending mail.]
System.Net.Mail.SmtpClient.Send(MailMessage message) +1811
Demos_Email.Page_Load(Object sender, EventArgs e) in d:\Training\BegASPNET\Site2\Demos\Email.aspx.cs:20
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
 
Old March 29th, 2011, 11:48 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
I try it again, this is the message:
Yes, I know, but you already posted that same error message. What I need to look at is the code that causes this exception.

Are you running Anti Virus software or a firewall on your machine? Can you try disabling it temporarily?

If it keeps failing, just use the SpecifiedPickupDirectory for local development as it works equally OK.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 29th, 2011, 02:39 PM
Registered User
 
Join Date: Mar 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Thanks a lot, I disable my antivirus and it does work.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Email Edward Colins BOOK: Beginning ASP.NET 4 : in C# and VB 9 September 19th, 2010 05:29 PM
Chapter 9. I can't figure how to configure my website for sending E-mail banditonehundred BOOK: Beginning ASP.NET 4 : in C# and VB 11 April 19th, 2010 07:21 PM
sending email ansalon5 ASP.NET 1.0 and 1.1 Basics 2 June 27th, 2006 01:34 PM
Sending Email soccers_guy10 Pro VB 6 3 February 11th, 2004 10:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.