locked
email form using GoDaddy RRS feed

  • Question

  • I am trying to have a form that a site visitor fills out emailed to the applicable addresses.  I am using ASP.NET 2.0 and Expression Web 1.  My host is GoDaddy.  When I submit the form, I receive the following error - "Mailbox name not allowed.  The server response was: sorry, your mail was administratively denied. (#5.7.1)."

    Here is the code that I am using.  Any help would be greatly appreciated.

    <%@ Page masterpagefile="Master.master" language="VB" title="Elitediting" %>
    <% @Import Namespace="System.Web.Mail" %>   
        <script runat="server">
       
       
            Protected Sub SubmitForm_Click(ByVal sender As Object, ByVal e As System.EventArgs)
                If Not Page.IsValid Then Exit Sub

                Dim SendResultsTo As String = "contactus@elitediting.com"
                Dim smtpMailServer As String = "relay-hosting.secureserver.net"
                Dim smtpMailServerPort As String = "25"
                Dim smtpUsername As String = "contactus@elitediting.com"
                Dim smtpPassword As String = "********"
                Dim MailSubject As String = "Contact Us Form"

                Try
                    Dim txtQ As TextBox = Me.FormContent.FindControl("TextBoxQ")
                    If txtQ IsNot Nothing Then
                        Dim ans As String = ViewState("hf1")
                        If ans.ToLower <> txtQ.Text.ToLower Or ans.ToUpper <> txtQ.Text.ToUpper Then
                            Me.YourForm.ActiveViewIndex = 3
                            Exit Sub
                        End If
                    End If

                    Dim FromEmail As String = SendResultsTo
                    Dim msgBody As StringBuilder = New StringBuilder()
                    Dim sendCC As Boolean = False

               
                    For Each c As Control In Me.FormContent.Controls
                        Select Case c.GetType.ToString
                            Case "System.Web.UI.WebControls.TextBox"
                                Dim txt As TextBox = CType(c, TextBox)
                                If txt.ID.ToLower <> "textboxq" Then
                                    msgBody.Append(txt.ID & ": " & txt.Text & vbCrLf & vbCrLf)
                                End If
                                If txt.ID.ToLower = "email" Then
                                    FromEmail = txt.Text
                                End If
                                If txt.ID.ToLower = "subject" Then
                                    MailSubject = txt.Text
                                End If
                            Case "System.Web.UI.WebControls.CheckBox"
                                Dim chk As CheckBox = CType(c, CheckBox)
                                If chk.ID.ToLower = "checkboxcc" Then
                                    If chk.Checked Then sendCC = True
                                Else
                                    msgBody.Append(chk.ID & ": " & chk.Checked & vbCrLf & vbCrLf)
                                End If
                               
                            Case "System.Web.UI.WebControls.RadioButton"
                                Dim rad As RadioButton = CType(c, RadioButton)
                                msgBody.Append(rad.ID & ": " & rad.Checked & vbCrLf & vbCrLf)
                            Case "System.Web.UI.WebControls.DropDownList"
                                Dim ddl As DropDownList = CType(c, DropDownList)
                                msgBody.Append(ddl.ID & ": " & ddl.SelectedValue & vbCrLf & vbCrLf)
                        End Select
                    Next
                    msgBody.AppendLine()
                   
                    msgBody.Append("Browser: " & Request.UserAgent & vbCrLf & vbCrLf)
                    msgBody.Append("IP Address: " & Request.UserHostAddress & vbCrLf & vbCrLf)
                    msgBody.Append("Server Date & Time: " & DateTime.Now & vbCrLf & vbCrLf)

                    Dim myMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
                    myMessage.To.Add(SendResultsTo)
                    myMessage.From = New System.Net.Mail.MailAddress(FromEmail)
                    myMessage.Subject = MailSubject
                    myMessage.Body = msgBody.ToString
                    myMessage.IsBodyHtml = False
                    If sendCC Then myMessage.CC.Add(FromEmail)

                   
                    Dim basicAuthenticationInfo As New System.Net.NetworkCredential(smtpUsername,smtpPassword)
                    Dim MailObj As New System.Net.Mail.SmtpClient(smtpMailServer,smtpMailServerPort)
                    MailObj.Credentials = basicAuthenticationInfo
                    MailObj.Send(myMessage)

                    Me.YourForm.ActiveViewIndex = 1
                Catch ex As Exception
        Me.YourForm.ActiveViewIndex = 2
        Response.Write("<span style='color:red'>" & ex.Message & "</span>")
       End Try
            End Sub

    </script>

    Thank you,
    Tim

    Sunday, November 30, 2008 10:00 PM

Answers

  • Well it is that simple:

    To get it to work all I had to was place it into the button event handler function, which is gets created between the <script></script> tags on the same page. If I was working with an attached file then the code would go into the same event function located in the aspx.cs or aspx.vb depending upon our programin preference.

    That was so difficult to explain.

    protected void Button1_Click(object sender, EventArgs e) { const string SERVER = "relay-hosting.secureserver.net"; System.Web.Mail.MailMessage oMail = new System.Web.Mail.MailMessage(); oMail.From = "interested@site.com"; oMail.To = "membership@site.com"; oMail.Subject = "Membership Request"; oMail.BodyFormat = System.Web.Mail.MailFormat.Html; oMail.Body = "<p> Name" + Name.Text + "</p><br/><p>SpouseName" + SpouseName.Text +"</p><br/><p>KidsName" + KidsName.Text + "</p><br/><p>Sent at: " + DateTime.Now; System.Web.Mail.SmtpMail.SmtpServer.Equals(SERVER); System.Web.Mail.SmtpMail.Send(oMail); oMail = null; }

    Thursday, April 23, 2009 7:05 AM

All replies

  • Have you tried asking GoDaddy?
    Monday, December 1, 2008 8:41 AM
  • Yes, a couple of times.  They said to change the From address, which did not help.
    Monday, December 1, 2008 2:00 PM
  • I have been fighting with this problem for about 2 weeks now.  After much searching & reading I'm not much farther along than I was at the beginning.  GoDaddy's support is worthless.  If I ever solve this problem, I will make a step by step how to on this forum. 

    Problem:  Created a website using asp.net masterpages.  Used Contact Form Generator for Expressions to create a contact form.  The form works perfectly if you send an email ONLY thru the GoDaddy system ... one GoDaddy hosted email to another GoDaddy hosted email ...  however, it does not work at all if you try sending an email from an outside source such as yahoo, gmail, etc. 

    GoDaddy says you must use their form mailer (gdform.asp or webmailerform.asp) and register your email with the form mailer through your hosting control center.  I did this.  This is the smtpMailServer As String = "relay-hosting.secureserver.net."  No user name or password is necessary.  The instructions to use their form mailer are for an html page only.  I created an html page with their instructions and it does work perfectly, but it seems crazy to have an entire website using masterpages & the one page that really could use asp.net features having to be on an html page.

    I am at the point that I will use an html page if I have to, but if I do, how do you do things like validate email addresses, put in spam protection, etc. 

    Can anyone help?


    The contact form generator form on the website:  http://conciergeserviceofkeywest.com/contact_us.aspx

    The code used for the form:  http://conciergeserviceofkeywest.com/contact-code.html

    Copy of email from GoDaddy Support:  http://conciergeserviceofkeywest.com/godaddy-support.html


    Thanks for any assistance you can give. 

    Tami
    • Edited by TamiG Thursday, February 12, 2009 8:06 PM fix hyperlink
    Thursday, February 12, 2009 8:05 PM
  • TamiG said:

    <<::snip::>>

    I am at the point that I will use an html page if I have to, but if I do, how do you do things like validate email addresses, put in spam protection, etc. 
    <<::snip::>>

    Tami

    I don't use GoDaddy, don't want to and never will (willingly), so I can't help with that part of your question. However, for the above question, the answer is javascript. Google "javascript validation" to find a number of solutions. There are also pre-written frameworks that will do the job for you. Google "javascript validation framework." As for spam control, I think you're probably talking about something like CAPTCHA, for which there are many solutions available on the Web.

    Spam control, CAPTCHA, obfuscation, validation, etc. all exist quite independently of either ASP or ASP.NET, so you have a plethora of options from which to choose your preferred solution. Or, you could just blow off GoDaddy and get a real hosting provider. <g,d,&r>

    cheers,
    scott

    Thursday, February 12, 2009 9:56 PM
  • Take a look at http://by-expression.com/forums/p/14/37.aspx#37 This is the code I used on GoDaddy to get the contact form in the Expression Web Portfolio Starter Kit working about 2 years ago.
    MS MVP Expression http://by-expression.com
    Thursday, February 12, 2009 11:28 PM
  • After 4 calls to GoDaddy I have tracked down the issue but do not know how to resolve it easily. It seems that when you publish a ASP forms page with the runat="server" the action gets repopulated with the aspx page.

    Example: You code <form method="post" action="_gdform/webformmailer.asp" runat="server"> in expression publish it to the webhost. If you open the page and look at the source code you will see the <form> code is changed to <form method="post" action="page.aspx" id="ASPFORM">.

    Does anyone know how or why this occurs or how to fix it?


    Tuesday, April 21, 2009 5:15 AM
  • . . .

    8. Find another provider, any provider, besides GoDaddy.
    Tuesday, April 21, 2009 1:43 PM
  • All ASP.NET output to the browser is HTML. ASP.NET runs on the server not in the browser. So doing a view source on the page will always show you HTML and possibly javascript if you are using the dotnet validation controls which validate first client side then a separate server side check.

    Did you even look at the link I posted earlier:

    Take a look at http://by-expression.com/forums/p/14/37.aspx#37  This is the code I used on GoDaddy to get the contact form in the Expression Web Portfolio Starter Kit working about 2 years ago.


    I know the code in that works because I've tested it and just ran another test before writing this post. You would need to change the this.field.text to whatever your form fields are but the part for sending the mail would be the same other than replacing the from with some email address for your domain and who you want to receive the mail on your end in the oMail.Bcc. It does use the relay-hosting.secureserver.net service at GoDaddy so that you can send to any email address not just those in your domain.

    FWIW, I don't use the GoDaddy form script first because it is classic asp and not asp.net so you can't use the validation tools in dotnet. Second, because it is limited to sending the results only to the address specified in your control panel so you can't send a confirmation copy and finally because you have very little flexibility in what you do with the results.
    MS MVP Expression Tutorials & Help http://by-expression.com and online instructor led Expression Classes
    • Edited by Cheryl D Wise Tuesday, April 21, 2009 1:52 PM added more information
    Tuesday, April 21, 2009 1:49 PM
  • Yes I have to agree. This has been a very frustrating process and this after being told that they do not make any changes. Well, it's completely BS. The only reason I am with them is the cost. Looking around for another ISP could find one that had windows servers for that 4-5 dollar price point. 



     
    Tuesday, April 21, 2009 1:50 PM
  • Yes I have to agree. This has been a very frustrating process and this after being told that they do not make any changes. Well, it's completely BS. The only reason I am with them is the cost. Looking around for another ISP could find one that had windows servers for that 4-5 dollar price point. 
    OK, I've just got to come in on this point. How much is your personal/professional time worth? For $10/month or less you can get a shared Windows server, all versions of PHP, ASP, and ASP.NET frameworks, SQL Server and MySQL, etc., basically everything GoDaddy offers and a ton more. And on a yearly plan that comes out to $8.33/month. The price delta is about what a Starbucks coffee once a month would cost you. It sounds to me as if you've already spent several hours dealing with this issue. At a conservative rate of $20/hour for your time, you've already paid for the differential between GoDaddy and a real hosting provider for full year, and then some, and you're still stuck with GoDaddy. Just sayin'...

    cheers,
    scott
    Tuesday, April 21, 2009 2:05 PM
  • Hi Cheryl,

    The issue is that you assume that people understand what type of file to create, where to put that code, or how to reference it once you've created the file. So while you have created some wonderful working code it does me no good because I do not know how to implement it.



    Tuesday, April 21, 2009 2:08 PM
  • I am not a professional just an educated hobbyist and web enthusiast. In this instance, I am doing work pro-bono for a local organization and keeping sending low means more money in other places.


    Tuesday, April 21, 2009 2:19 PM
  • The I suggest that you spend some time learning. Working with forms requires some understanding of how server side code works. The example I give is really quite easy once you have even the slightest understanding of how dotnet works.

    There are many free resources on the net including http://w3schools.com which has CSS, HTML and even server side lessons. Microsoft has a ton of resources including videos and tutorials on dotnet available all over the internet starting with http://www.asp.net/LEARN/videos/. Many of them using the free Visual Web Developer Express because Expression Web doesn't have much to help you by way of server side code http://www.microsoft.com/express/vwd/ the two work well together.

    Using generators will only get you so far and as you saw leads to lots of fustration.
    MS MVP Expression Tutorials & Help http://by-expression.com and online instructor led Expression Classes
    Tuesday, April 21, 2009 3:01 PM
  • I have spent plenty of time learning and I completely understand how the code works. What 90% of programmers forget is that those who are self taught have not had the luxury of learn the background and larger picture of how everything interacts. Imagine learning a language one word at a time and never knowing there is actually an alphabet or understanding how sentence structure are formed.

    The internet is full of code snippets and it's easy to understand a snippit of code but if you have no understand where to place this useful code that you understand then it's worthless. With the plethora of file types .cs, .ascx, .css, .aspx, .asp, etc... it becomes daunting what kind of file to create and how things interact within the file. My issue is not with understanding your code and making it fit what I need but the reality is I have no knowledge of what to do with it once I've made the changes.

    So here is some feedback from someone that would look at your example for help: Yes I saw your example, Yes I understood how to change the code to work for me, but with out understanding what kind of file to create, or futher details I said great looks good but don't know what to do next.

    So thanks for the links, I will go off and learn more words and try to piece together a sentence.







    Tuesday, April 21, 2009 7:48 PM
  • What 90% of programmers forget is that those who are self taught have not had the luxury of learn the background and larger picture of how everything interacts. Imagine learning a language one word at a time and never knowing there is actually an alphabet or understanding how sentence structure are formed.

    That doesn't make sense.  I'm self-taught and fully understand the big picture.

    --
    Chris Hanscom - Microsoft MVP
    Resource Center | Veign's Blog | Web Development Help
    Tuesday, April 21, 2009 7:54 PM
  • What 90% of programmers forget is that those who are self taught have not had the luxury of learn the background and larger picture of how everything interacts. Imagine learning a language one word at a time and never knowing there is actually an alphabet or understanding how sentence structure are formed.

    That doesn't make sense.  I'm self-taught and fully understand the big picture.

    --
    Chris Hanscom - Microsoft MVP
    Resource Center | Veign's Blog | Web Development Help
    Good for you! I am glad you've achieved this. I on the other hand am still trying to figure it out. So maybe you can help me understand on what I should do with Cheryl's code? Because I have yet to figure it out.

    Tuesday, April 21, 2009 8:03 PM
  • Follow her advice and read up on the technology.  Learn the big picture.
    --
    Chris Hanscom - Microsoft MVP
    Resource Center | Veign's Blog | Web Development Help
    Tuesday, April 21, 2009 8:15 PM
  • As representatives of MS I would expect more.... maybe answer my question of how to implement the code but I guess not.... Good day.

    Tuesday, April 21, 2009 8:22 PM
  • I'm not a representative of MS nor do i have any ties to MS.  I am just a forum member who gives his time freely to answer questions.

    You need to step back and do some learning.  People can only help so much.  Step back, learn the technology (read up on the links Cheryl posted) then review your question.

    Everyone here is donating there time.  You have to be prepared to put the hours in learning.
    --
    Chris Hanscom - Microsoft MVP
    Resource Center | Veign's Blog | Web Development Help
    Tuesday, April 21, 2009 8:26 PM
  • Man I would be happy with an answer like you have to place the code into a aspx.cs file and reference it as a submit button action. I am not looking for a step by step tutorial. I just haven't grasp the concept of how the files all get reference at this point. I may have unintentionally made myself out to be completely oblivious but I'm not. I am trying to make a point that not everyone in these forms has a full understanding when you see a snipit of code on where to place it.
    Tuesday, April 21, 2009 8:41 PM
  • I am using GoDaddy for some time now and emailing user creation details back to user,
    copied some code from MS sample projects and adapted to suit.
    Don't know if this will help for your case but here is some of the code that works for me:

    <asp:CreateUserWizard runat="server" id="CreateUserWizard1" BorderWidth="1px" BorderColor="#E6E2D8" BorderStyle="Solid" BackColor="#E3EAEB" Font-Size="X-Small" Font-Names="Verdana" CancelDestinationPageUrl="users.aspx" LoginCreatedUser="False" FinishDestinationPageUrl="users.aspx" ContinueDestinationPageUrl="users.aspx" onsendingmail="SendingMail">
       ...............
       <MailDefinition From="noreply@yourdomain.com" BodyFileName="MailFile.txt" ></MailDefinition>
       ..............
      </asp:CreateUserWizard>

      public void SendingMail(object sender, MailMessageEventArgs e)
      {
        // Set MailMessage fields.
        e.Message.IsBodyHtml = false;
        e.Message.Subject = "New user details for Yourdomain.com secure access.";
        e.Message.Body = e.Message.Body.Replace("<%PasswordQuestion%>", CreateUserWizard1.Question);
        e.Message.Body = e.Message.Body.Replace("<%PasswordAnswer%>",   CreateUserWizard1.Answer);  
        

       }
      
    }
    Tuesday, April 21, 2009 9:48 PM
  • I don't know what "programmers" you are talking to but I for one am "self-taught" learning from some of those resources I mentioned and a lot of other tutorials. It doesn't take knowing the "big picture" to understand what the code bits I used do and if you learn anything about forms processing in dotnet then "where" it goes is obvious and not part of any big picture.   The "big picture" is when you are architecting a site, something that I've also learned how to do by the seat of my pants.

    As for the code in the link it is how to get the contact form that comes in one of the Expression starter kits to actually send email from GoDaddy since the code included in the starter kit doesn't work on GoDaddy servers.  The quick way to understand where it goes is to look at the stareter kits. The oSomething are variables either from the form or from the dotnet framework and where it goes depends on how you created your form and whether you are using code behind or on page processing. That choice depends on how you are working on the site and how much of your code you want to be reusable on multiple pages.

    Oh and I'll jump ahead and repsond to your comment "as a representative of MS" - I am not a representative of MS, nor is Chris or any other MVP. An MVP is an award given to people who voluntarily spend time answering questions on MS programs. We are not employees of MS and in fact Microsoft employees are not eligible to receive the award. Look at http://mvp.support.microsoft.com/ for information on the MVP award.
    MS MVP Expression Tutorials & Help http://by-expression.com and online instructor led Expression Classes
    Tuesday, April 21, 2009 11:03 PM
  • No, I'm sorry but the answer isn't that simple.

    Unlike Classic ASP or PHP you can't just say "put this code on a page called mail.asp and use "<form action="mail.asp" method="post">" and everything will work. THAT is why we listed places for you to learn the basic concepts so you can determine whether you should be using aspx, aspx.cs, aspx.vb, ascx, or something else.

    That is why you were given resources for learning the basics since just because you can sort of use a snippet doesn't mean that you should when you don't have an understanding of basic concepts.
    MS MVP Expression Tutorials & Help http://by-expression.com and online instructor led Expression Classes
    Tuesday, April 21, 2009 11:15 PM
  • Well it is that simple:

    To get it to work all I had to was place it into the button event handler function, which is gets created between the <script></script> tags on the same page. If I was working with an attached file then the code would go into the same event function located in the aspx.cs or aspx.vb depending upon our programin preference.

    That was so difficult to explain.

    protected void Button1_Click(object sender, EventArgs e) { const string SERVER = "relay-hosting.secureserver.net"; System.Web.Mail.MailMessage oMail = new System.Web.Mail.MailMessage(); oMail.From = "interested@site.com"; oMail.To = "membership@site.com"; oMail.Subject = "Membership Request"; oMail.BodyFormat = System.Web.Mail.MailFormat.Html; oMail.Body = "<p> Name" + Name.Text + "</p><br/><p>SpouseName" + SpouseName.Text +"</p><br/><p>KidsName" + KidsName.Text + "</p><br/><p>Sent at: " + DateTime.Now; System.Web.Mail.SmtpMail.SmtpServer.Equals(SERVER); System.Web.Mail.SmtpMail.Send(oMail); oMail = null; }

    Thursday, April 23, 2009 7:05 AM
  • Agree's with Rollo1002
    you would have less headaches on trying to follow up on things.
    reasons like this is why i stick with php and will never use asp.

    when i ran a windows server ya .net looks very appealing.
    but getting the right answers when you need them instead of spending 30+hrs reading.
    is pretty hard to find decent people to help.

    this is why most forums have issues.

    thanks rollo for the tip and thanks cheryl for a basic start.

    if your going to answer you should atleast give more detail what to do with the final.
    even if its a link to the answer to make someone read. instead of dig for the answer.

    Sorry if this is rude. but Like me Was asked to do something to fix a issue due to a new host.
    If Rollo didnt figure it out i would have beat my head and rewrote there whole site. instead of wasting time with asp.

    [Snip] Edited for Decorum
    Wednesday, June 24, 2009 6:31 PM
  • Well it is that simple:

    To get it to work all I had to was place it into the button event handler function, which is gets created between the <script></script> tags on the same page. If I was working with an attached file then the code would go into the same event function located in the aspx.cs or aspx.vb depending upon our programing preference.

    That was so difficult to explain.
    protected void Button1_Click(object sender, EventArgs e)
    
    {
    
        const string SERVER = "relay-hosting.secureserver.net";
    
        System.Web.Mail.MailMessage oMail = new System.Web.Mail.MailMessage();
    
                           
    
        oMail.From = "interested@site.com";
    
        oMail.To = "membership@site.com";
    
        oMail.Subject = "Membership Request";
    
    
    
        oMail.BodyFormat = System.Web.Mail.MailFormat.Html;
    
        oMail.Body = "<p> Name" + Name.Text + "</p><br/><p>SpouseName" + SpouseName.Text +"</p><br/><p>KidsName" + KidsName.Text + "</p><br/><p>Sent at: " + DateTime.Now;
    
        System.Web.Mail.SmtpMail.SmtpServer.Equals(SERVER);
    
        System.Web.Mail.SmtpMail.Send(oMail);
    
    
    
        oMail = null;
    
    }<br/><br/>
    
    



    Not sure if updating to II7 or some other backend update caused by GoDaddy has caused an issue not but the code above needs to be change. The System.Web.Mail is no longer working (at least for me it stopped) and had to be changed to use System.Net.Mail. Don't fret here is the new code as there are a few other items that change with the new method:

    protected void Button1_Click(object sender, EventArgs e)
    {
       
        const string SERVER = "relay-hosting.secureserver.net";
        System.Net.Mail.MailMessage oMail = new System.Net.Mail.MailMessage();

        oMail.To.Add(Email.Text); //email.text is a text box in my form where I am collecting the email
        oMail.From = new System.Net.Mail.MailAddress("name@yoursite.xxx");
        oMail.Bcc.Add("name@yoursite.xxx"); //I use the BCC to send me a copy of the form-mailer
        
        
        oMail.Subject = "Subject of Mail Here";

        oMail.IsBodyHtml = true;  //will send an HTML formated email

    // Below is the message body surround text with quotes " " and as you can see I have radio button and information from text boxes too. The break return in quotes help with formating of the message

        oMail.Body = "Membership: " + RadioButtonMembership.SelectedValue + "<br/>MemberType: "
            + RadioButtonMembershipType.SelectedValue + "<br/>Payment Method: " + Payment.SelectedValue +"<br/>First Name: "
            + FName.Text + "<br/> Last Name: " + LName.Text + "<br/> Spouse Name: " + SpouseName.Text + "<br/>Kids Name: " + KidsName.Text
            + "<br/>Address: " + Address.Text + "<br/>Address1: " + Address1.Text + "<br/>City: " + City.Text + " State: " + State.SelectedValue
            + " Zip: " + Zip.Text +"<br/>Phone: " + PhoneNumber.Text + "<br/> Email: " + Email.Text + "<br/> Sent at: " + DateTime.Now;

        System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(SERVER);

        smtp.Send(oMail);

        oMail = null;

       
    }

    Saturday, June 27, 2009 4:03 PM
  • Yes for Godaddy hosting it is a problem.But i have solved this problem in this way.I have a button in my 'Contact Us' page...in 'Send' button click event i have written this code..hope it will work..Notice that you have to mention the "To" and "From" (who send the mail and receiver mail) will be same.yes you just append the sender mail id with 'body',so receiver can see ..who sent the mail.but 'To' and 'From' will be same as ur domain mail address.

    Example:if your mail id in domain like this:info@domain.com

    so for this case 'Mail To':info@domain.com

    'Mail From':info@domain.com

    You just append the orginal sender mail id with body..not in Mail From option.



    Here is the code:


     protected void btnSend_Click(object sender, EventArgs e)
            {
                lblAlert.Visible = false;
                string subject = txtSubject.Text.Trim();
                string _mailfromemail = txtEmail.Text.Trim();
                string _mailto = "info@domain.com";
                string message = txtMessage.Text.Trim();
                StringBuilder sb = new StringBuilder();
                sb.Append(message);
                sb.Append(" <br/> ");
                sb.Append("\n");
                sb.Append(" <br/> ");
                sb.Append("Mail Sent By:");
                sb.Append(" ");
                sb.Append(_mailfromemail);

                string body = sb.ToString();

                if (string.IsNullOrEmpty(body))
                {
                    lblAlert.Visible = true;
                    lblAlert.Text = "Plese mention the mail body.";
                    return;
                }
                bool status = SendEmail(_mailto,_mailfromemail, subject, body);

                if (status)
                {
                    lblAlert.Visible = true;
                    lblAlert.Text = "your mail has been sent successfully";
                    txtSubject.Text = "";
                    txtEmail.Text = "";
                    txtMessage.Text = "";
                   
                 
                }
                else
                {
                    lblAlert.Visible = true;
                    lblAlert.Text = "sorry! your mail could not be sent";
                  
                }

            }
            static bool SendEmail(string ToAddr,string senderEmail, string Subject, string Body)
            {
                bool result;

                try
                {
                    MailMessage Msg = new MailMessage();
                    Msg.From = new MailAddress("info@domain.com", senderEmail);
                    Msg.Subject = Subject;
                    Msg.Body = Body;
                    Msg.To.Add(ToAddr);
                    Msg.BodyEncoding = System.Text.Encoding.UTF8;
                    Msg.Priority = MailPriority.High;
                    Msg.IsBodyHtml = true;
                    SmtpClient SMTP = new SmtpClient("relay-hosting.secureserver.net", 25);
                    SMTP.Send(Msg);

                    result = true;
                }
                catch (Exception Err)
                {
                    result = false;
                }

                return result;
            }


    Friday, August 14, 2009 11:19 AM
  • Yes for Godaddy hosting it is a problem.But i have solved this problem in this way.I have a button in my 'Contact Us' page...in 'Send' button click event i have written this code..hope it will work..Notice that you have to mention the "To" and "From" (who send the mail and receiver mail) will be same.yes you just append the sender mail id with 'body',so receiver can see ..who sent the mail.but 'To' and 'From' will be same as ur domain mail address.

    Example:if your mail id in domain like this:info@domain.com

    so for this case 'Mail To':info@domain.com

    'Mail From':info@domain.com

    You just append the orginal sender mail id with body..not in Mail From option.



    Here is the code:


     protected void btnSend_Click(object sender, EventArgs e)
            {
                lblAlert.Visible = false;
                string subject = txtSubject.Text.Trim();
                string _mailfromemail = txtEmail.Text.Trim();
                string _mailto = "info@domain.com";
                string message = txtMessage.Text.Trim();
                StringBuilder sb = new StringBuilder();
                sb.Append(message);
                sb.Append(" <br/> ");
                sb.Append("\n");
                sb.Append(" <br/> ");
                sb.Append("Mail Sent By:");
                sb.Append(" ");
                sb.Append(_mailfromemail);

                string body = sb.ToString();

                if (string.IsNullOrEmpty(body))
                {
                    lblAlert.Visible = true;
                    lblAlert.Text = "Plese mention the mail body.";
                    return;
                }
                bool status = SendEmail(_mailto,_mailfromemail, subject, body);

                if (status)
                {
                    lblAlert.Visible = true;
                    lblAlert.Text = "your mail has been sent successfully";
                    txtSubject.Text = "";
                    txtEmail.Text = "";
                    txtMessage.Text = "";
                   
                 
                }
                else
                {
                    lblAlert.Visible = true;
                    lblAlert.Text = "sorry! your mail could not be sent";
                  
                }

            }
            static bool SendEmail(string ToAddr,string senderEmail, string Subject, string Body)
            {
                bool result;

                try
                {
                    MailMessage Msg = new MailMessage();
                    Msg.From = new MailAddress("info@domain.com", senderEmail);
                    Msg.Subject = Subject;
                    Msg.Body = Body;
                    Msg.To.Add(ToAddr);
                    Msg.BodyEncoding = System.Text.Encoding.UTF8;
                    Msg.Priority = MailPriority.High;
                    Msg.IsBodyHtml = true;
                    SmtpClient SMTP = new SmtpClient("relay-hosting.secureserver.net", 25);
                    SMTP.Send(Msg);

                    result = true;
                }
                catch (Exception Err)
                {
                    result = false;
                }

                return result;
            }


    Hi,

    This code looks great, but i keep getting an error. (Mailbox name not allowed. The server response was: sorry, relaying denied from you location [**.***.**.***] (#5.7.1)")

    I played with this all day yesterday and kept on getting error massages like this and got now where.
    Is this code still working for somebody else or is it Godaddy that is the problem ?
    I regret starting with them already.
    Tuesday, November 3, 2009 12:22 PM
  • Rollo1002,I like your solution but I am hoping you can repost it in VB if all possible, I am having the same problem and everything I tried will not work.  please consider a simple solution where you show the entire code. I have a button in my master page that take me to an aspx page that all I want is for enter the sender email and the comment and pusha button to to send the email to my unfotuntaly "godaddy" web mail site. thank you and for anyone else who want to jump in on this thread.
    also do the buton event handler need to be in the <script> section? and yes I am newby to dot net.
    Abe

    Saturday, November 7, 2009 5:14 AM
  • Here's an idea--just leave GoDaddy. Hosting's cheap, and there are better hosts all over the place. Even if you left early, you wouldn't be out much money. I move every client who comes to me off of GoDaddy when I re-do their site.
    Saturday, November 7, 2009 2:12 PM
  • thanks for the reply, unfortunatly this a a friend for mine I am helping with her website, I will never host with godaddy just from the all around bad and cheap reputation.
    Sunday, November 8, 2009 10:06 PM
  • Give me a day to work out the solution as I am just getting back from vacation and catching up on a few other things. I will try to provide a solution in VB. After doing much research on this the issue is not a GoDaddy specific issue but a more improved way that MS servers are handling post back events. You will need to make these changes eventually no matter where you host as upgrades to the hosting servers are conducted.

    Sunday, November 8, 2009 10:52 PM
  • I'll look forward to seeing Rollo1002's code. Just a heads up but make sure you include the godaddy anti-spam ibits of their relay server and whatever else they may require.
    MS MVP Expression Tutorials & Help http://by-expression.com and online instructor led Expression Classes
    Monday, November 9, 2009 12:36 AM
  •  Private Function SendMail() As Boolean
    Try
    Dim SMTP As New SmtpClient
    Dim MailMsg As New MailMessage
    Dim MailFrom As New MailAddress("testemail@godaddy.ca")
    Dim MailTo As New MailAddress("testemail@godaddy.ca")
    Dim HostServer As String = "relay-hosting.secureserver.net"

    MailMsg.From = MailFrom
    MailMsg.To.Add(MailTo)
    MailMsg.Subject = txtName.Text & " " & txtSubject.Text.Trim
    MailMsg.Body = "Sent at: " & DateTime.Now & vbNewLine _
    & txtEmailAddress.Text & vbNewLine _
    & txtBody.Text.Trim
    MailMsg.IsBodyHtml = True
    MailMsg.Priority = MailPriority.High
    SMTP.Host = HostServer

    SMTP.Send(MailMsg)
    SendMail = True
    Catch ex As Exception
    SendMail = False
    End Try

    Return SendMail

    End Function


    Protected Sub cmdSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSend.Click

    If txtEmailAddress.Text <> "" And txtName.Text <> "" And txtBody.Text <> "" Then

    If SendMail() = False Then
    txtBody.BackColor = Drawing.Color.Red
    txtEmailAddress.BackColor = Drawing.Color.Red
    txtSubject.BackColor = Drawing.Color.Red
    txtName.BackColor = Drawing.Color.Red
    txtBody.Text = "There was an error sending your comment. Please make sure that all the fields are filled in correctly then try again."
    Else
    Response.Redirect("HomePage.aspx")
    End If

    Else
    If txtBody.Text = Nothing Then
    txtBody.BackColor = Drawing.Color.Red
    End If
    If txtEmailAddress.Text = Nothing Then
    txtEmailAddress.BackColor = Drawing.Color.Red
    End If
    If txtName.Text = Nothing Then
    txtName.BackColor = Drawing.Color.Red
    End If
    If txtSubject.Text = Nothing Then
    txtSubject.BackColor = Drawing.Color.Red
    End If
    End If

    End Sub
    You cannot use use this to debug. If you want to test it out to have to upload it to godaddy server first. Thats the mistake I made, I did not know that you could not test sending an email from godaddy servers from debugger. So the code above works perfect for me. Where I have put "testemail@godaddy.ca" put in the email address that you want the emails to be sent to. I use the same email for To: and From: then the email address that the user types in I just add that as part of the subject. I have lost alot of tears and said some really bad words trying to figure this out, and the only thing that i was missing was that you have to upload it to there servers first like i mentioned above. If the above code is causing trouble please let me know.
    • Edited by bguenther Monday, November 9, 2009 1:26 PM Code layout
    Monday, November 9, 2009 1:23 PM
  • You cannot use use this to debug. If you want to test it out to have to upload it to godaddy server first. Thats the mistake I made, I did not know that you could not test sending an email from godaddy servers from debugger. So the code above works perfect for me. Where I have put "testemail@godaddy.ca" put in the email address that you want the emails to be sent to. I use the same email for To: and From: then the email address that the user types in I just add that as part of the subject. I have lost alot of tears and said some really bad words trying to figure this out, and the only thing that i was missing was that you have to upload it to there servers first like i mentioned above. If the above code is causing trouble please let me know.
    It sould be noted that this may not be unique to GoDaddy, at least in some of the symptoms. Trying to test SMTP send from the local system is problematic for several reasons. To my knowledge, neither the VWD nor the EW development server is configured for or supports SMTP. And if you set up an IIS-based Web, or Apache/PHP, either must also be properly set up for SMTP and the correct credentials used.

    Finally, and most problematic, these days most ISPs (including mine) block all email relays to prevent SPAM. Attempting to send an email from your local SMTP server, through theirs, on your regular ISP service account, will only earn you a bounce message, 505 if memory serves, stating that relays are not permitted. In a way, that's actually a successful test, since it confirms that the message did get sent and went at least as far as the ISP's server.

    In the current instance, and perhaps others, as well, there are also the unique requirements of a particular provider to account for, so I would say that in the general case you should always try to test from your provider's servers, both to account for these other factors and because, when you come down to it, that's where it will be running when active anyway, so you get the most accurate testing environment that way.

    cheers,
    scott
    Plural's don't have apostrophe's. It seem's sometime's that any word's ending in "s" get a gratuitous apostrophe. Apostrophe's are used to indicate possessive's and elision's (contraction's or abbreviation's).
    Monday, November 9, 2009 2:05 PM
  • I am not going to reinvent the wheel if this works.

    For additional detail for those that need it you would either place  this code in a "code behind file" a file ending with .aspx.vb or within the <script></script> tags of the <filename>.aspx of the form page.

    To get this exact code to run in the <filename>.aspx page you will need a button with id named "cmdSend_Click" to get the mail to send when the user click the button.

    Changes you can or will need to make are:


    Dim MailFrom As New MailAddress(testemail@godaddy.ca) // Change this email address to yours

    Dim MailTo As New MailAddress(testemail@godaddy.ca) // Change this email address where you want to receive the form


    MailMsg.Subject = txtName.Text & " " & txtSubject.Text.Trim // You can either pull the information from a form field as shown or can be hard fixed


    MailMsg.Body = "Sent at: " & DateTime.Now & vbNewLine _

                                       & txtEmailAddress.Text & vbNewLine _

                                       & txtBody.Text.Trim

    // You will want to change this information depending upon your form and the information you are relaying the current code pulls from a textbox on the <filename>.aspx page named txtEmailAddress and txtBody


    One thing to note is that the above code uses validation before sending the form this is not necessary if you are using aspx validation controls. If you are then delete everything in the cmdSend_Click() function  and type SendMail() then Response.Redirect("<yourconfirmationpage>.aspx")

    • Edited by Rollo1002 Monday, November 9, 2009 4:08 PM grammer changes
    Monday, November 9, 2009 4:01 PM
  • You guys are awsome, I will try it and let you know, thank you
    Tuesday, November 10, 2009 2:57 AM
  • Like I said you guys are awsome, bguenther example was a cut and past and work from the first time. 
    Thanks to all of you, Cheryl D Wise, bguenther, paladyn and Rollo1002 all comments and advise will be take seriously in the final version.
    Abe 

    Test Version

    Protected

     

    Sub cmdSend_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdSend.Click

     

    'If txtEmailAddress.Text <> "" And txtName.Text <> "" And txtBody.Text <> "" Then

     

    'If SendMail() = False Then

     

    'txtBody.BackColor = Drawing.Color.Red

     

    'txtEmailAddress.BackColor = Drawing.Color.Red

     

    'txtSubject.BackColor = Drawing.Color.Red

     

    'txtName.BackColor = Drawing.Color.Red

     

    'txtBody.Text = "There was an error sending your comment. Please make sure that all the fields are filled in correctly then try again."

     

    'Else

     

    'Response.Redirect("HomePage.aspx")

     

    'End If

     

    'Else

     

    'If txtBody.Text = Nothing Then

     

    'txtBody.BackColor = Drawing.Color.Red

     

    'End If

     

    'If txtEmailAddress.Text = Nothing Then

     

    'txtEmailAddress.BackColor = Drawing.Color.Red

     

    'End If

     

    'If txtName.Text = Nothing Then

     

    ' txtName.BackColor = Drawing.Color.Red

     

    ' End If

     

    'If txtSubject.Text = Nothing Then

     

    'txtSubject.BackColor = Drawing.Color.Red

     

    'End If

     

    'End If

    SendMail()

     

    End Sub

     

    Private Function SendMail() As Boolean

     

    Try

     

    Dim SMTP As New SmtpClient

     

    Dim MailMsg As New MailMessage

     

    Dim MailFrom As New MailAddress("webmaster@zzzzzzzbestfriend.com")

     

    Dim MailTo As New MailAddress("webmaster@zzzzzzzbestfriend.com")

     

    Dim HostServer As String = "relay-hosting.secureserver.net"

    MailMsg.From = MailFrom

    MailMsg.To.Add(MailTo)

    MailMsg.Subject =

    "My Mail Subject"

    MailMsg.Body =

    "Sent at: My Mail Body " '& DateTime.Now & vbNewLine _& txtEmailAddress.Text & vbNewLine _& txtBody.Text.Trim

    MailMsg.IsBodyHtml =

    True

    MailMsg.Priority = MailPriority.High

    SMTP.Host = HostServer

    SMTP.Send(MailMsg)

    SendMail =

    True

     

    Catch ex As Exception

    SendMail =

    False

     

    End Try

     

    Return SendMail

     

    End Function

    Tuesday, November 10, 2009 4:33 AM
  • bguenther or aelkassih ...would you guys by any chance have an example of how you created the <form>?
    • Proposed as answer by adolix Wednesday, November 25, 2009 8:04 AM
    Tuesday, November 24, 2009 2:47 AM
  • Instead of this hassle, I suggest you try any of those remotely hosted form services, like 123 Contact Form. You setup your contact form there, enter your email, copy& paste the HTML code on your website, and all messages will be delivered to your inbox.
    Wednesday, November 25, 2009 8:06 AM
  • I got it to work by changing the from address to an address that is valid on the godaddy server.  I set up an email for webmaster@mydomain and used that address for the from address and the error went away and the mail got sent.
    Saturday, September 11, 2010 10:03 PM
  • Jack M. This is a very old thread and I have been trying to follow it since I am hosting at GoDaddy. Any way that you could put your final working copy of your feedback_form.html and your jmailexample.asp? And most important where you placed these files into your hosting?

    I have setup the form mail with a valid email from inside of GoDaddy. Verified that I have windows hosting and PHP turned on. Their are plenty of great examples on how to build forms and plenty of ASP scripting. I just cannot make the square peg fit correctly into the round hole.

    <form method="post" action="jmailExample.asp"> gives me a 404 error.

    Any help will be appreciated.  

    Wednesday, September 14, 2011 1:36 AM
  • If you are using "classic" asp, then you do not need PHP - they are completely different and unrelated languages.

    The <form method="post" action="jmailExample.asp"> tag implies that jmailExample.asp is in the same folder as the page calling it, and the 404 error says that either jmailExample.asp is not in that folder, or a page that jmailExample.asp links to is not where jmailExample.asp thinks it is.


    Ron Symonds
    Microsoft MVP (Expression Web)

    www.rxs-enterprises.org/fp
    Wednesday, September 14, 2011 8:00 AM
  • Thanks _Ronx for the reply. I should have stated that ASP and ASP.net and PHP5 are supported.

    I tried putting a copy of jmailexample.asp in the same directory as my feedback_form.htm and in the root directory and changing the specified path. I have been able to change the error that I get from a 404 to a 500 when both files are collocated.

    I even switched position of post with the action= just for test even though all that I read it should not matter.

    <form action="../../jmailExample.asp" method="post">  . Thanks ALL.

    Wednesday, September 14, 2011 6:22 PM
  • I do not know if this is helpful but..I am running ASP classic and hosted on GoDaddy..

     

    I include the following code in an include file that is included with all webpages:

    <%

    Dim sendURL,smtpurl,MailerConfig,Mailer
    sendUrl="http://schemas.microsoft.com/cdo/configuration/sendusing"
    smtpUrl="http://schemas.microsoft.com/cdo/configuration/smtpserver"
    Set MailerConfig=CreateObject("CDO.Configuration")
    MailerConfig.Fields.Item(sendUrl)=2 ' cdoSendUsingPort
    MailerConfig.Fields.Item(smtpUrl)="relay-hosting.secureserver.net"
    MailerConfig.Fields.Update

    Set Mailer=CreateObject("CDO.Message")
    Set Mailer.Configuration=MailerConfig
    Mailer.From="webmaster@mydomain.com"

    %>

    change the from line to your domain name...

     

    then in the code i call it like this:

     <%

    Mailer.To ="email name you are sending it to"

     Mailer.Subject = "Subject line text"
        Mailer.HTMLBody = "text of email"
        Mailer.Send

        Set Mailer = Nothing 

     %>

     

    THis code works as of the date of this post

     --Richard

    http://DLDHistory.com

    The Unique Disneyland History Site


    • Edited by dldhistory Saturday, February 4, 2012 4:58 AM
    Saturday, February 4, 2012 4:56 AM
  • When this thread was started, George W. Bush was still President! Who do you think you're talking to?

    The thread was already marked as being answered, but now here it is, bumping current threads off the front page for no good reason. On top of that, the original question is about ASP.NET 2.0, not the out-of-date classic ASP. And further, it's not even a question about Expression Web; it should have been posted in the asp.net forum or a GoDaddy (shudder) forum.

    Never resurrect dead threads in any forum on the internet. This, and much more, is covered in the Forum FAQ and Guidelines - Start Here, which you clearly didn't bother to read. We've been using internet forums for ages, and the rule for every one is: enter, look around, lurk, read the guidelines (they are there for a reason), follow the guidelines, and only then post if what you have to say or ask is pertinent yo the forum. Universal rules.


    Comic Sans walks into a bar. The bartender says, "Get out! We don't serve your type."
    • Edited by Bill Pearson Saturday, February 4, 2012 1:25 PM
    • Proposed as answer by lpad1112 Monday, March 19, 2012 1:32 PM
    • Unproposed as answer by lpad1112 Monday, March 19, 2012 1:32 PM
    Saturday, February 4, 2012 1:22 PM
  • You could always try using an online form builder such as Formstack. Should save you a lot of time and hassel with coding forms, and there are tons of features you can take advantage of.
    Monday, March 19, 2012 1:34 PM
  • Interesting to learn that it is possible to survive when one has the IQ of a shoelace.

    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Monday, March 19, 2012 6:06 PM