Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 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 November 23rd, 2007, 03:28 PM
Authorized User
 
Join Date: Oct 2007
Location: , , .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 7 Email setting for "forgot password?"

Hi experts,

I am testing Chapter 7 sample program.
How can I set up email send/receive for "Login>forgot passowrd?"?
My personal email address is hyungdoo@gmail.com. So I put it to Chapter 7 sample program's web.config as follows. But it doesn't work.
Your kind advice would be appreciated.

Thanks,

====web.config========

.
.
?lt;appSettings>
    <add key="EmailFrom" value="hyungdoo@gmail.com" />
    <add key="EmailTo" value="hyungdoo@gmail.com" />
    <add key="PageTitle" value="Wrox Photo Album"/>
    ?lt;add key="CurrentTheme" value="cleanred" />
?lt;/appSettings>
.
.
<system.net>
    <mailSettings>
     <smtp deliveryMethod="Network">
        <network host="smtp.gmail.com" port="25" />
     </smtp>
    </mailSettings>
</system.net>
 
Old November 23rd, 2007, 04:34 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Can you define "doesn't work"? Do you get an error? If so, what error do you get?

Also, I don't think you can use Google's mail server like that without putting a username and password in the <network /> element.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old November 26th, 2007, 12:04 PM
Authorized User
 
Join Date: Oct 2007
Location: , , .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Thanks for your advice.

1. If I add my username and password like follows, I have follwing error messages.
   <mailSettings>
      <smtp deliveryMethod="Network">
        <network host="smtp.gmail.com" userName="hyungdoo" password="mypassword" port="25" />
      </smtp>
    </mailSettings>

Server Error in '/Modification' Application.
--------------------------------------------------------------------------------

A from e-mail address must be specified in the From property or the system.net/mailSettings/smtp config section.
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.Web.HttpException: A from e-mail address must be specified in the From property or the system.net/mailSettings/smtp config section.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): A from e-mail address must be specified in the From property or the system.net/mailSettings/smtp config section.]
   System.Web.UI.WebControls.MailDefinition.CreateMai lMessage(String recipients, IDictionary replacements, String body, Control owner) +1411614
   System.Web.UI.WebControls.LoginUtil.CreateMailMess age(String email, String userName, String password, MailDefinition mailDefinition, String defaultBody, Control owner) +183
   System.Web.UI.WebControls.LoginUtil.SendPasswordMa il(String email, String userName, String password, MailDefinition mailDefinition, String defaultSubject, String defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) +341
   System.Web.UI.WebControls.PasswordRecovery.Attempt SendPasswordQuestionView() +653
   System.Web.UI.WebControls.PasswordRecovery.Attempt SendPassword() +66
   System.Web.UI.WebControls.PasswordRecovery.OnBubbl eEvent(Object source, EventArgs e) +101
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
   System.Web.UI.WebControls.Button.OnCommand(Command EventArgs e) +115
   System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +163
   System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

2. If I change it like this:
      <mailSettings>
          <smtp from="hyungdoo@gmail.com">
              <network host="smtp.gmail.com" userName="hyungdoo" password="my password" port="25" />
          </smtp>
      </mailSettings>

Then I have follwoing messages:

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first u2sm991187pyb
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.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first u2sm991187pyb

3. If I change it like this:
      <mailSettings>
          <smtp from="postmaster@myhostingname.net">
              <network host="smtp.myhostingname.net" userName="myusername" password="mypassword" port="25" />
          </smtp>
      </mailSettings>

Then I have two kinds of results:
1) If the username's email address is in this hosting site, it's good to send out.
2) If the username 's email address is not in this hosting site, it's not. The error message from here is:

Mailbox unavailable. The server response was: <sungsook.park@gmail.com> No such user here
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.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: <sungsook.park@gmail.com> No such user here

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


I hope these several status will be helpful to you.

Thanks,



--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1378; ASP.NET Version:2.0.50727.1378

 
Old November 26th, 2007, 12:28 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

For the SSL error, you need to set the EnableSsl property on the SmtpClient instance like this:

smtpClient.EnableSsl = true


Hope this helps,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old November 29th, 2007, 05:45 PM
Authorized User
 
Join Date: Oct 2007
Location: , , .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

I did it successfully in Chapter 6 like this:
<mailSettings>
 <smtp from="myname@myhostingsite.com">
  <network host="localhost" userName="" password="" port="25" />
 </smtp>
</mailSettings>

Thanks for your kind help.


 
Old November 29th, 2007, 06:28 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Great. You're welcome....

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old April 1st, 2008, 11:33 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Using The Beer House Contact.aspx page, How would I enableSsl in the code-behind:

      protected void btnSubmit_Click(object sender, EventArgs e)
      {
         try
         {
            // send the mail
            MailMessage msg = new MailMessage();
            msg.IsBodyHtml = false;
            msg.From = new MailAddress(txtEmail.Text, txtName.Text);
            msg.To.Add(new MailAddress(Globals.Settings.ContactForm.MailTo));
            if (!string.IsNullOrEmpty(Globals.Settings.ContactFor m.MailCC))
               msg.CC.Add(new MailAddress(Globals.Settings.ContactForm.MailCC));
            msg.Subject = string.Format(Globals.Settings.ContactForm.MailSub ject, txtSubject.Text);
            msg.Body = txtBody.Text;
            new SmtpClient().Send(msg);

            // show a confirmation message, and reset the fields
            lblFeedbackOK.Visible = true;
            lblFeedbackKO.Visible = false;
            txtName.Text = "";
            txtEmail.Text = "";
            txtSubject.Text = "";
            txtBody.Text = "";
         }
         catch (Exception)
         {
            lblFeedbackOK.Visible = false;
            lblFeedbackKO.Visible = true;
         }
      }



Quote:
quote:Originally posted by Imar
 For the SSL error, you need to set the EnableSsl property on the SmtpClient instance like this:

smtpClient.EnableSsl = true


Hope this helps,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old April 1st, 2008, 11:58 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi James,

How is the Beer house related to this?

Anyway, is my previous example not enough to get you started? You need to set EnableSsl to true. In your case, you create an instance of SmtpClient and call Send in one line, so you need to split that:

SmtpClient myClient = new SmtpClient()
myClient.EnableSsl = true;
myClient.Send(msg);

Cheers and hope this helps,

Imar



---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old April 1st, 2008, 12:42 PM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply. I have another post at http://p2p.wrox.com/topic.asp?TOPIC_ID=70246 which has the settings you specided, but with those settings, I have a problem. Could you look at my other thread and see if you have a solution?
 
Old April 23rd, 2008, 02:40 PM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

along with [hdpark's] post :
"2. If I change it like this:
      <mailSettings>
          <smtp from="hyungdoo@gmail.com">
              <network host="smtp.gmail.com" userName="hyungdoo" password="my password" port="25" />
          </smtp>
      </mailSettings>

Then I have follwoing messages:

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first u2sm991187pyb
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. "

has there been a way to fix this ? or what do we need to insert to make this work .. localhost on port 25 works but im not going to be the one hosting this so i dont want people connecting to me computer..





Similar Threads
Thread Thread Starter Forum Replies Last Post
forgot sa password, unable to change... help happygv SQL Server 2000 14 April 29th, 2010 02:26 AM
FORGOT EXCEL PASSWORD prasanta2expert Excel VBA 4 March 17th, 2010 05:23 AM
Forgot password for phpmyadmin AMP_Engineer BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 September 8th, 2004 04:59 AM
email password fzilz BOOK: ASP.NET Website Programming Problem-Design-Solution 1 March 17th, 2004 12:48 AM
Forgot password? developerz BOOK: ASP.NET Website Programming Problem-Design-Solution 1 November 30th, 2003 04:36 PM





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