Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 February 2nd, 2009, 12:40 AM
Registered User
 
Join Date: May 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 9 pps 314-316 Contact Form User Control

I am unable to get the Contact Form to work. When I click the Send button I get this error in Internet Explorer 8:

Transaction failed. The server response was: 5.7.1 <*******@*****.***>: Recipient address rejected: Access denied

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: Transaction failed. The server response was: 5.7.1 <[email protected]>: Recipient address rejected: Access denied

Source Error:


Line 53: Line 54: SmtpClient mySmtpClient = new SmtpClient();Line 55: mySmtpClient.Send(myMessage);Line 56: Line 57: lblMessage.Visible = true;

Source File: c:\BegASPNET\Site\Controls\ContactForm.ascx.cs Line: 55

++++++++++++++++++++++++++++++++++++
Here is the code in my ContactForm.ascx.cs:
++++++++++++++++++++++++++++++++++++
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
publicpartialclassControls_ContactForm : System.Web.UI.UserControl
{
protectedvoid Page_Load(object sender, EventArgs e)
{
}
protectedvoid CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
if (txtPhoneHome.Text != string.Empty || txtPhoneBusiness.Text != string.Empty)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
protectedvoid btnSend_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string fileName = Server.MapPath("~/App_Data/ContactForm.txt");
string mailBody = System.IO.File.ReadAllText(fileName);
mailBody = mailBody.Replace("##Name##", txtName.Text);
mailBody = mailBody.Replace("##Email##", txtEmailAddress.Text);
mailBody = mailBody.Replace("##HomePhone##", txtPhoneHome.Text);
mailBody = mailBody.Replace("##BusinessPhone##", txtPhoneBusiness.Text);
mailBody = mailBody.Replace("##Comments##", txtComments.Text);
MailMessage myMessage = newMailMessage();
myMessage.Subject = "Response from web site";
myMessage.Body = mailBody;
myMessage.From = newMailAddress("[email protected]", "my real name");
myMessage.To.Add(newMailAddress("[email protected]", "my real name"));
SmtpClient mySmtpClient = newSmtpClient();
mySmtpClient.Send(myMessage);
lblMessage.Visible = true;
FormTable.Visible = false;
}
}
}

++++++++++++++++++++++++++++++++++++++++
Here is the the code from my web.config file
+++++++++++++++++++++++++++++++++++++++++

<system.net>
<
mailSettings>
<
smtpdeliveryMethod="Network"from="my real name &lt;[email protected]&gt;">
<
networkhost="smtp.*****.***userName="myusername"password="mypassword"/>
</
smtp>
</
mailSettings>
</
system.net>

++++++++++++++++++++++++++++++++++++++++++++++

Can you see what I have wrong in all this? Thanks.

Last edited by Featheriver; February 6th, 2009 at 02:21 PM..
 
Old February 2nd, 2009, 03:19 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 Featheriver,

I can only guess as I don't know the setup or rules of your ISP's mail serer, but my guess is that [email protected] is not a valid "from" address; instead of your user name, try your real address; e.g. the one that starts with featheriver.

BTW: you may want to edit your previous post and remove references to your real e-mail address and mail server; never a good idea to post these details on-line....

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:
Featheriver (February 10th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 6 pps 226-228 User Selected Theme Featheriver BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 April 20th, 2011 07:08 AM
Chapter 9 p. 314: How to import a namespace? Featheriver BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 January 31st, 2009 07:58 PM
Chapter 8 pps 272-273 Featheriver BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 January 31st, 2009 05:00 PM
Chapter 7 Navigation Try IT Out pps. 246-247 workib BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 May 22nd, 2008 08:39 PM
Contact Form myself Classic ASP Basics 1 November 18th, 2006 11:16 AM





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