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

10 jQuery Custom Scrollbar Plugins

10 jQuery Custom Scrollbar Plugins If you ever wanted to add some custom scrollbars to your website, to scroll the contents and the default browser scrollbars just doesn’t match up with your design, than make sure you check this list of 10 jQuery custom scrollbar plugins. Hope you find the following information helpful. 1. jScrollPane – custom cross-browser scrollbars Kelvin Luck’s jScrollPane was originally developed in December 2006. It is a jQuery plugin which provides you with custom scrollbars which work consistently across all modern browsers. You can style the scrollbars using simple CSS and they degrade gracefully where JavaScript is disabled. 2. Plugin JQuery : Scrollbar This page is written in french so use Google’s translate service to translate this page to your preferred language. Download is available for the plugin.  The purpose of this plugin is to add a scrollbar to the item of your choice, to view any content which is larger than the size – vizible sp

connect ftp with gridview / display files in gridview from ftp or server

HTML Markup Below is the HTML Markup of the page, where I have an ASP.Net control  FileUpload  to upload files, a  Button control to trigger file uploads and an ASP.Net GridView control to display the files from folder. < asp : FileUpload   ID ="FileUpload1"   runat ="server"   /> < asp : Button   ID ="btnUpload"   runat ="server"   Text ="Upload"   OnClick ="UploadFile"   /> < hr   /> < asp : GridView   ID ="GridView1"   runat ="server"   AutoGenerateColumns ="false"   EmptyDataText   =   "No files uploaded">      < Columns >          < asp : BoundField   DataField ="Text"   HeaderText ="File Name"   />          < asp : TemplateField >              < ItemTemplate >                  < asp : LinkButton   ID ="lnkDownload"   Text   =   "Download"   CommandArgument   =   ' &

Working with Ajax UpdatePanel in asp.net

During work with our applications if we entered any values in textbox controls and click on a button in form we will see full postback of our page and we will lost all the controls values whatever we entered previously this happend because of postback. If we want to avoid this full postback of page and round trip to server we need to write much code instead of writing much code we can use ajax updatepanel control. Ajax updatepanel will help us to avoid full postback of the page i.e., avoid refresh of the whole page content with postback and stop flickering of the page which is associated with a postback and allows only partial postbacks. By using Ajax updatepanel we can refresh only required part of page instead of refreshing whole page. Ajax updatepanel works on very smooth concepts. but in some cases we got stuck while using Ajax updatepanel. But you need not to worry. Here i am showing you how to resolve the issues for different cases Lets start with very basic use of A