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

By pass single quote or special character in ck editor or fck editor in any language

By pass single quote or special character in ck editor or fck editor in any language like asp.net , php etc   whenever we are using ckeditor or fckeditor we are able to pass the data successfully but if single quote  '  or symbols like '|>|<|\\+ is present in our content then it will not save the data I search a lot for the solution of this topic.  Every post is provide some rumors but finally after using ck editor for long time, i found the solution. so friends now you can pass any type of data in fckeditor or ck editor  ------------------------------------------------------------------------------------------------------------------------ AdditionalNumericEntities With this setting, you can define a set of characters which will be translated to their relative numeric entities in the output HTML. This is quite useful if you don't want single quotes (') to be inserted in the text (being transformed to ′):...
10 must read SQL Server A buddy of mine Ted Krueger writes some really interesting SQL Server posts. Most of these posts focus more on administration than on developer stuff but still stuff that is useful to a developer. Here are 10 of my favorites, I liked these and you will too! 6 ways to import data into SQL Server Recover a database without the ldf file Dynamic column names and fields in SSRS (Custom Matrix) Rebuild master and restore system databases from complete disk failure Do not truncate your ldf files! Proactive Deadlock Notifications Troubleshooting Blocking 101 on SQL Server Not a fan of the Report Manager in SSRS? Using SSRS procedures to get the job done Dynamic Data Sources in SSRS Quick Data Model creation off SSAS Data Source in SSRS