Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 6th, 2011, 06:56 AM
Authorized User
Points: 303, Level: 6
Points: 303, Level: 6 Points: 303, Level: 6 Points: 303, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: , , United Kingdom.
Posts: 71
Thanks: 23
Thanked 0 Times in 0 Posts
Default Email demo

Hi Imar hope you are well. I am having a problem sending email through the Email demo form. I have played about with it using many different settings – too many to mention. My code is as below and I have checked and got the smtp address of my mail server (as an IP address), a port number plus I was told that I will not need to pass in a login or password (even though I have tried it anyway).

The error I am getting is
Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.

My Code behind file.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;

publicpartialclassDemos_Email : BasePage
{
protectedvoid Page_Load(object sender, EventArgs e)
    {
MailMessage myMessage = newMailMessage();
            myMessage.Subject = "Text Message";
            myMessage.Body = "Hello World, from Planet Wrox";
            myMessage.From = newMailAddress("******@.net", "MarkH");
            myMessage.To.Add(newMailAddress("******@.net", "This should be the receivers name"));
SmtpClient mySmtpClient = newSmtpClient();
            mySmtpClient.Send(myMessage);
    }
}


My web.config



Code:
 
<?xmlversion="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
       <system.web>
    <pagestheme="Monochrome">
      <!--removed styleSheetTheme="Monochrome" it messed up DarkGrey.Css-->
      <controls>
        <addtagPrefix="Wrox"tagName="Banner"src="~/Controls/Banner.ascx" />
      </controls>
    </pages>  
              <compilationdebug="true"targetFramework="4.0"/>
       </system.web>

  <!--my code for email-->
  <system.net>
  <mailSettings>    
    <smtpdeliveryMethod="Network"from = "MarkH &lt;******@.net&gt;">
      <networkhost= "**.*.**.***"port="25"/>
    </smtp>
  </mailSettings>
</system.net>
  <!--my code for email-->

  </configuration>



Many Thanks
Mark
Reply With Quote
  #2 (permalink)  
Old October 6th, 2011, 08:54 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Quote:
This mail server requires authentication when attempting to send to a non-local e-mail address.
Looks like you need to assign a user name and password, as explained on page 318.

Hope this helps,

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!
Reply With Quote
  #3 (permalink)  
Old October 6th, 2011, 09:38 AM
Authorized User
Points: 303, Level: 6
Points: 303, Level: 6 Points: 303, Level: 6 Points: 303, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: , , United Kingdom.
Posts: 71
Thanks: 23
Thanked 0 Times in 0 Posts
Default

Hi Imar and thanks for your prompt reply. Sorry I should have included that i uploaded my web site via the Visual Studio copy option. Hope this is fine or should I ftp it.

Regards
Mark
Reply With Quote
  #4 (permalink)  
Old October 6th, 2011, 12:47 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Mark,

The way you deploy doesn't matter. Take a look at my initial reply: you need to assign a user name and password in web.config as explained on page 318.

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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Structure Demo Elad Reznik BOOK: Beginning Microsoft Visual Basic 2010 1 October 5th, 2010 05:51 AM
Bug on demo site vsjc BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 2 October 30th, 2009 09:07 AM
Chapter 4, demo.controls benjii82 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 October 26th, 2009 03:20 PM
wrox web site demo yesil65 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 October 2nd, 2008 01:06 PM
Chapter 8, Meno Demo sjar BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 4 June 20th, 2006 10:01 AM



All times are GMT -4. The time now is 03:45 PM.


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