Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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 December 17th, 2008, 02:36 AM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default A Hosted Email Problem....

I'm just getting started with a personal site based on TBH, and have (with help from jimi) solved one problem today, but am now onto another:

I'm trying to get outbound email working. I'm using godaddy.com to host the site and got their smtp server info... I took the Contact form and modified the web.config description as follows:

Code:
      <mailSettings>
         <!-- <smtp deliveryMethod="Network"> -->
         <smtp deliveryMethod="PickupDirectoryFromIis" from="info@latzky.com">
            <network defaultCredentials="true" host="smtpout.secureserver.net" port="25" />
         </smtp>
      </mailSettings>
I've also tried smtp.latzky.com as my smtp server although that was a pipedream.... I can't simulate at home, even by adding one of the freeware smtp servers to my Vista pc since my local dsl service has secure outbound mail, so I'm trying to debug the process from the hosted site with no luck.

Can anyone point me in the right direction? I've ensured that info@latzky.com is a valid email address, but no joy.....

Thanks!
__________________
Mike - NorCal
 
Old December 17th, 2008, 10:15 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Well, first, you need to know the correct name of your outgoing SMTP server. It sounds as though you're just guessing.

Second, you would need to supply credentials in the form of a username and password.

Code:
      <mailSettings>
         <smtp from="info@latzky.com">
            <network host="smtp.YourSmtpServer.net" userName="YourUserName" password="YourPassword" />
         </smtp>
      </mailSettings>
Since you are sending directly this way, you don't need to specify the pickup directory.

I am not sure if godaddy requires use of an alternate port, or if you need to use SSL to log into SMTP.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old December 17th, 2008, 04:08 PM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Well, I've now called godaddy several times with different answers. Apparently, they support an smtp relay server in ASP.NET 3.5 but don't say they don't support it for 2.0.

They don't explicitly tell me which of several smtp servers I should use for this, but I've tried them all. I've also tried Lee's example directly with the assmued correct server name.

Still no joy.

Is there anyway to step-through debug the code so I can see where it fails? I can't do this from my local PC because godaddy doesn't allow remote connections to their SQL Server db, so I can't remotely run the site....

I figure if I can see the code in step-through, I can figure out what's wrong....

Thanks.
__________________
Mike - NorCal
 
Old December 17th, 2008, 04:10 PM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I should add they suggest CDONTS, but I'm not sure how or what to do about that, and figure someone has dealt with before.....

I also verified that new registration emails don't go out either.....
__________________
Mike - NorCal
 
Old December 17th, 2008, 06:51 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

If they suggested you use CDONTS, they must really have their heads up their buttocks.

You should not even have to ask them about the SMTP server. If you have enough information to set up this address to successfully send and receive in Outlook, you should be able to do it.

Setting up an email address to send mail in Outlook requires you to provide the smtp server name, so it's not like this information is some heavily-guarded state secret or somethng. ;) That's the name you would use. You'd also use the same user name and password that you'd use in Outlook.

In Outlook, under Advanced account settings, there would be a port number for outgoing connections. 25 is the default, but many servers use 587 instead. If you don't specify one in web.config, it will try to use port 25, but if your server wants 587 or some other number, you'll have to specify one explicitly.

It would also have a checkbox in the account settings to indicate "Use the following type of encrypted connection". If it says None, that's cool. If it says SLL, or something else, you will have to handle the SendingMail events in your code to configure your connection to use SSL.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old December 17th, 2008, 06:56 PM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks Lee - I'll have to try some more of these variables and see if I can do something about this. Today, at home, I use AT&T/Yahoo which requires SSL, etc. I can receive email from the godaddy system to my domain email ID's, and will have to try the additions you discuss....

Thanks.
__________________
Mike - NorCal
 
Old December 17th, 2008, 08:30 PM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

The previous try didn't work, but they do have this example for CDOSYS that seems to be the same constructs as in TBH:

Code:
// language -- C#
// import namespace
using  System.Web.Mail;

private void SendEmail()
{
   const string SERVER = "relay-hosting.secureserver.net";
   MailMessage oMail = new  System.Web.Mail.MailMessage();
   oMail.From =  "emailaddress@domainname";
   oMail.To =  "emailaddress@domainname";
   oMail.Subject = "Test email  subject";
   oMail.BodyFormat = MailFormat.Html; //  enumeration
   oMail.Priority = MailPriority.High; //  enumeration
   oMail.Body = "Sent at: " + DateTime.Now;
   SmtpMail.SmtpServer = SERVER;
   SmtpMail.Send(oMail);
   oMail = null; // free up  resources
}
Since I can't see the step by step execution on their server, I can't figure out why it's not working.... any ideas on how to step-through debug this ont he hosted site to see what;s not connecting?
__________________
Mike - NorCal
 
Old December 17th, 2008, 10:11 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

You still have to do this to send mail programmatically. It's just that with the other method, you are creating a SmtpClient instance, which grabs the server and credentials from web.config instead of specifying them in your code. Look at the code behind of Contact.aspx for an example.

Also, if you set the correct information in web.config, there should be no reason that this wouldn't work on your local server. But either way, if you want to see what's happening, wrap the whole deal in a try-catch block (which you should do anyway, and which is already done in Contact.aspx) and set the breakpoint at the beginning of the try. Step through line by line. If there is a problem with the information being grabbed from web.config, the new SmtpClient().Send(msg); line should throw an exception. Then examine the exception and it will tell you what happened.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old December 18th, 2008, 12:09 AM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I must be really incredibly stupid - everything seems set up on my system for debugging, but the debugger isn't breaking at the breakpoint. So I set up a text box, and added code to write out the contents of each component. Seems OK, but the form creates an exception at the email address which is simply one of my regular sbcglobal email addresses. It adds my name in quotes, then the email address in between <> which seems to create the problem.

If I knew why I couldn't debug properly, I'd probably be able to figure this out, but my Debug profile appears correct...

Really stupid question, but is there something I need to set besides the debug profile and setting a breakpoint that should enable debugging? I feel like I'm in a parallel universe.....
__________________
Mike - NorCal
 
Old December 18th, 2008, 12:33 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Excuse the stupid question, but are you running the app in debug mode, or are you just choosing "View In Browser?" If you do View In Browser the app will never stop at a breakpoint.

Anyhoo, if you're not in debug mode then the exception is bubbling up to the page, so at least we can get some kind of clue. It looks to me like it doesn't like the email address string.

Can you post your code you're using to mail, your web.config mailsettings section, and the exact exception message you are getting?
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
getting formatted output in hosted powershell Mike Shepard BOOK: Professional Windows PowerShell Programming ISBN: 978-0-470-17393-0 3 October 8th, 2009 03:57 AM
Hosted Form of Component angelboy C# 2005 7 March 31st, 2008 02:36 PM
Hosted BeerHouse and sub directory gb012993 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 January 16th, 2008 01:48 AM
Events with IIS hosted remoting koraykazgan C# 1 May 1st, 2007 03:49 PM
Moving App to Hosted site dthoma128 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 13 December 19th, 2006 03:59 PM





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