Skip to main content

(Solved) Failure sending mail in Godaddy Server

(Solved) Failure sending mail in Godaddy Server


I know that this is an old thread.  At the same time, I worked on this problem for two weeks.  I wish that I had the final answer a couple of weeks ago!
If you have shared hosting at GoDaddy.com, you need to use these credentials WHILE your are developing your application:
In the namespaces you have to add
using System.Net.Mail;

or if you are not using any .cs file the you can insert namespace as
<%@ Import Namespace="System.Net.Mail" %>
//for mail(from,to,subject,message)

MailMessage msg = new MailMessage("frommailid@yourdomain.com", "tomailid@yourdomain.com", "hello" , "your message");
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtpout.secureserver.net";    // Only works locally (development time)
smtp.EnableSsl = false;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("your_email@gmail.com", "your_password");
smtp.Port = 25; 
smtp.Send(msg);

Label1.Text = "congratulation";
Then, when you are about to PUBLISH your application, you need to change your smtp host to this line:
smtp.Host = "relay-hosting.secureserver.net";  // ONLY WORKS WHEN PUBLISHED TO GODADDY SHARED HOSTING
The "relay-hosting" line ONLY works when the application is on the shared hosting platform.  In other words, it only works AFTER you publish your website.

COMPLETE CODE
You can user the following complete  code


<%@ Page Language="C#" %>
<%@ Import Namespace="System.Net.Mail" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void Button1_Click(object sender, EventArgs e)
    {
         
//for mail(from,to,subject,message)

MailMessage msg = new MailMessage("frommailid@yourdomain.com", "tomailid@yourdomain.com", "hello" , "your message");
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtpout.secureserver.net";    // Only works locally (development time)
smtp.EnableSsl = false;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("your_email@gmail.com", "your_password");
smtp.Port = 25; 
smtp.Send(msg);

Label1.Text = "congratulation";  
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <form id="form1" runat="server">
    <div>
    Name: 
        <asp:TextBox ID="Textname" runat="server"></asp:TextBox>
&nbsp;Email id: 
        <asp:TextBox ID="Textmail" runat="server" ToolTip="Enter Your Email id" 
            Width="180px"></asp:TextBox>
&nbsp;Message:  
        <asp:TextBox ID="Textmsg" runat="server" Height="50px" TextMode="MultiLine" 
            Width="500px"></asp:TextBox>
        <br />
        <br />
        <br />
&nbsp;
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
&nbsp;&nbsp;
        <asp:Label ID="Label1" runat="server" ForeColor="#FF6666" Text="test"></asp:Label>
    
    </div>
    </form>
</body>
</html>

Comments

Post a Comment

Popular posts from this blog

Contact us Forms Links

Hi Friends This is my second post to blogger.com. and this time I am going to share my few useful resource links with you all. This post is regarding to “How to create contact us form to the html page” So please go to the following sites 1) http://wufoo.com/gallery/templates/forms/contact-form/ Thats it
Hello Friends This is an important moment for me! This is the first blog I’ve ever written. It’s something I’ve wanted to do for a long time, but wasn’t sure how to do it, where, when, or even if. And finally, now here I am. People say that blogs are like a diary (do I hide it under my bed, lock it with a key? Tell it all my secrets? It seems like a wonderful place to share my thoughts with you, or what I do.) It’s going to be fun sharing my thoughts with you, outside the context of a book. Ok let me tell you about myself. I am a I.T Engineer and having 2 year experience about the I.T Sector. After Completion of my graduation i worked as a "Web Designer" for 1.3 years then i Switch my profile to software engineer and I am working as a Software engineer from 6 months. so basically my blogs are all bout to the new technologies, interesting and important codes and some useful resources. For more about myself please visit my website: http://www.lokeshchadha.co.cc/ . 1)..Downl...

Three Tier Architecture in asp.net using c#

3-Tier Architecture in asp.net using c# In this asp.net tutorial you will learn how to implement 3-tier architecture in asp.net using c#. 3-Tier architecture is also called layered architecture. Some people called it n-tier architecture. Layer architectures are essentially objects and work in object oriented environment just like asp.net. 3-tier architecture is a very well known architecture in the world of software development, it doesn't matter whether you are developing web based application or desktop based, it is the best architecture to use. 3-Tier Architecture in asp.net using c# 3-Tier architecture consists of 1) UI or Presentation Layer 2) Business Access Layer or Business Logic Layer 3) Data Access Layer Presentation Layer Presentation layer consists of pages like .aspx or desktop based form where data is presented to users or getting input from users. Business Logic layer or Business Access Layer Business logic layer contains all of the business logic. Its r...