Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Security.Cryptography;
using System.Text;
using System.Data.SqlClient;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Collections;
using System.Net.Mail;

public partial class get_in_touch : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            string From = txtemail.Text.Trim();
            string to = "XXX";
            string subject = "GET IN TOUCH!";
            string Body = "Name:- " + txtname.Text + Environment.NewLine + "<br>" +
                          "Mobile Number:- " + txtmobile.Text + Environment.NewLine + "<br>" +
                          "Email:- " + txtemail.Text + Environment.NewLine + "<br>" +
                          "Company/Organization:- " + txtcompany.Text + Environment.NewLine + "<br>" +
                          "Message:- " + txtmess.Text + Environment.NewLine;
            MailMessage msg = new MailMessage(From, to);
            msg.Subject = subject;
            AlternateView view;
            SmtpClient client;
            StringBuilder msgText = new StringBuilder();
            msgText.Append(Body);
            view = AlternateView.CreateAlternateViewFromString(msgText.ToString(), null, "text/html");
            msg.AlternateViews.Add(view);
            client = new SmtpClient();
            client.EnableSsl = false;
            client.Port = 25;
            client.Host = "relay-hosting.secureserver.net";
            client.Credentials = new System.Net.NetworkCredential("xxx", "xxx");
            client.Send(msg);
            Response.Redirect("mail-success.html");
            Reset();

        }

        catch (Exception ex)
        {

            Trace.Warn(ex.Message);

        }

    }
    public void Reset()
    {
        txtname.Text = "";
        txtmobile.Text = "";
		txtemail.Text = "";
		txtcompany.Text = "";
		txtmess.Text = "";
		
    }
}


What I have tried:

This code is running fine on all other windows hosting servers, the only problem is on the godaddy windows hosting server.

Note : If I fill the form on the live site and enter the email ID of the domain, then the email is sent properly.
Posted
Updated 8-Apr-24 3:13am
v2
Comments
CHill60 8-Apr-24 8:09am    
Perhaps contacting GoDaddy support would be appropriate?
Richard Deeming 9-Apr-24 6:31am    
NB: Using the user-supplied address as the "from" address of the email will usually result in your message being blocked, since your server isn't authorised to send email from random domains.

Servers which do allow this - an "open relay" - are usually abused by spammers / phishers, and blocked by most receiving servers.

The usual approach is to send from an address in your own email domain, and add the user-supplied address to the "reply-to" addresses.

As you are having a problem with a hosting provider, the best thing for you to do is to get in touch with GoDaddy and talk to their support team. You can find their support here[^].
 
Share this answer
 
Comments
Member 11290735 8-Apr-24 8:48am    
I asked Godaddy for support, but godaddy support team told me to change the SMTP relay, but the problem was not solved.

https://in.godaddy.com/help/send-form-mail-using-an-smtp-relay-server-953
Pete O'Hanlon 8-Apr-24 9:15am    
Have you tried the steps here? https://uk.godaddy.com/help/send-email-using-systemnetmail-in-windows-hosting-19291
Member 11290735 8-Apr-24 9:26am    
Note : If I fill the form on the live site and enter the email ID of the domain, then the email is sent properly.
Sounds like you are running into a SPF,DKIM, DMARC authentication issue.

SPF is a DNS record that tells the receiving email server if the sending server is a valid sender for the domain in the from field of the email. In your case you have the field txtemail which is entered by the person filling out the form and is used as the from email in the email. You can't do this anymore.

Use a from email of your domain if you have the correct SPF record in DNS for it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900