It looks like from your code you are indicating that the From email field is based on the email address that the user populates. Mail server mail should reject this and only allow email from the example.com domain name, or possibly the server name. I came across this before when your From field should be the source domain of the site ...
If you want the recipient of the form to respond directly, use the ReplyTo field, not
MailMessage mailMessage = new MailMessage();
Hope this helps ...
EDIT:
After you have edited your question, the above is still relevant. You probably cannot use the From address outside your own domain domain example.com . If you want to send two copies of the request (one for contact@example.com , and the other for the user as confirmation), you just need to add the To property:
MailMessage mailMessage = new MailMessage();
If you need to add a simple confirmation email you can also do:
try { MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress(" abc@example.com "); mailMessage.To.Add(new MailAddress(" contact@example.com ")); mailMessage.ReplyTo = new MailAddress(txtEmailId.Text); mailMessage.Subject = txtSubject.Text; mailMessage.Body = txtMessage.Text; mailMessage.IsBodyHtml = false; mailMessage.Priority = MailPriority.High; SmtpClient sc = new SmtpClient("relay-hosting.secureserver.net");
source share